Tcl:如何改变可执行文件名的行为



我在使用python解释器从c可执行文件中使用TCL时遇到一些问题。由于某些原因,它不能加载<fullpath>Tix843.dll。但是当直接(从python)运行python代码时,它确实工作。dll的路径/名称是正确的…使用依赖项跟踪器,我只看到Tkinter试图加载fix dll,但找不到它…

在tcl中跟踪了各种路径后,我只能检测到一个差异:nameofexecutable。当直接从python运行时,它是python.exe的路径,但当从我的c可执行文件运行时,它(显然)是path/name of the executable

在tcl/tk中,我注意到nameofexecutable用于设置很多路径,所以我认为这导致了我的问题。

我试图防止这个问题的事情:

  1. 将dll的路径添加到系统路径
  2. 将dll的路径添加到$auto_path -> no change
  3. 在调用PySys_SetArgv之前设置c可执行文件的argv[0] -> no change

我做了什么愚蠢的事情或者我如何设置nameofexecutable ?有没有其他方法可以解决这个问题?

编辑:再次与依赖walker检查,现在我不知道发生了什么…下面是结果:

00:00:07.800: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:program files (x86)python27dllsTCL85.DLL" at address 0x02468871.
00:00:07.800: Loaded "c:program files (x86)python27tclreg1.2TCLREG12.DLL" at address 0x00440000.  Successfully hooked module.
00:00:07.816: Unloaded "c:program files (x86)python27tclreg1.2TCLREG12.DLL" at address 0x00440000.
00:00:07.816: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.832: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:program files (x86)python27dllsTCL85.DLL" at address 0x0246889C.
00:00:07.832: Loaded "c:program files (x86)python27tclreg1.2TCLREG12.DLL" at address 0x00440000.  Successfully hooked module.
00:00:07.832: Unloaded "c:program files (x86)python27tclreg1.2TCLREG12.DLL" at address 0x00440000.
00:00:07.832: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/reg1.2/tclreg12.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.925: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:program files (x86)python27dllsTCL85.DLL" at address 0x02468871.
00:00:07.925: Loaded "c:program files (x86)python27tcltix8.4.3TIX843.DLL" at address 0x04480000.  Successfully hooked module.
00:00:07.925: Unloaded "c:program files (x86)python27tcltix8.4.3TIX843.DLL" at address 0x04480000.
00:00:07.925: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.941: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) called from "c:program files (x86)python27dllsTCL85.DLL" at address 0x0246889C.
00:00:07.956: Loaded "c:program files (x86)python27tcltix8.4.3TIX843.DLL" at address 0x04480000.  Successfully hooked module.
00:00:07.956: Unloaded "c:program files (x86)python27tcltix8.4.3TIX843.DLL" at address 0x04480000.
00:00:07.956: LoadLibraryExW("C:/Program Files (x86)/Python27/tcl/tix8.4.3/Tix843.dll", 0x00000000, LOAD_WITH_ALTERED_SEARCH_PATH) returned NULL. Error: The specified module could not be found (126).
00:00:07.956: LoadLibraryA("shell32") called from "c:program files (x86)python27dllsTK85.DLL" at address 0x024BBACD.
00:00:07.956: LoadLibraryA("shell32") returned 0x75480000.

所以它有时可以找到dll,但不是总是这样,然后失败

nameofexecutable属性是在Tcl库初始化期间设置的(来自Tcl_FindExecutable()的参数,我不知道它是如何被调用的,但肯定是:它被用来做各种各样的事情)。你不能把它设置在任何其他点上。然而,Tcl实际上并没有在很多你不能覆盖的地方使用这个值。

相反,您应该考虑将TCLLIBPATH环境变量设置为一个Tcl目录列表,以便在其中搜索包定义。或者,您可以将目录添加到Tcl中的auto_path全局变量中(与lappend auto_path一起),该变量包含要查找的实际位置列表(实际上,它也查找该变量中列出的位置的直接子目录)。当然,这必须在加载Tix之前完成。

最有可能的是,C程序找不到fix .dll,因为它不在您的路径中。Python可以找到它,因为它与Python可执行文件在同一个目录中,或者在Python知道的子目录中。尝试将dll路径添加到path环境变量中。

相关内容

  • 没有找到相关文章

最新更新