0

我对使用 python 解释器的 ac 可执行文件的 tcl 有一些问题。由于某种原因,它无法加载<fullpath>Tix843.dll. 但是当直接(从 python)运行 python 代码时,它确实可以工作。dll的路径/名称是正确的......使用依赖walker我只看到Tkinter试图加载tix dll但找不到它......

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

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

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

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

我在做一些愚蠢的事情还是我该如何设置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)\python27\dlls\TCL85.DLL" at address 0x02468871.
00:00:07.800: Loaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.DLL" at address 0x00440000.  Successfully hooked module.
00:00:07.816: Unloaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.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)\python27\dlls\TCL85.DLL" at address 0x0246889C.
00:00:07.832: Loaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.DLL" at address 0x00440000.  Successfully hooked module.
00:00:07.832: Unloaded "c:\program files (x86)\python27\tcl\reg1.2\TCLREG12.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)\python27\dlls\TCL85.DLL" at address 0x02468871.
00:00:07.925: Loaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.DLL" at address 0x04480000.  Successfully hooked module.
00:00:07.925: Unloaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.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)\python27\dlls\TCL85.DLL" at address 0x0246889C.
00:00:07.956: Loaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.DLL" at address 0x04480000.  Successfully hooked module.
00:00:07.956: Unloaded "c:\program files (x86)\python27\tcl\tix8.4.3\TIX843.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)\python27\dlls\TK85.DLL" at address 0x024BBACD.
00:00:07.956: LoadLibraryA("shell32") returned 0x75480000.

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

4

2 回答 2

1

nameofexecutable属性是在 Tcl 库初始化期间设置的(源自Tcl_FindExecutable()我不知道如何准确调用的参数,但绝对是:它用于做各种事情)。你不能在任何其他点设置它。然而,Tcl 实际上并没有将这个值用于很多你无法覆盖的地方。

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

于 2013-05-27T09:37:21.630 回答
0

很可能,C 程序找不到 Tix.dll,因为它不在您的路径中。Python 可以找到它,因为它与 python 可执行文件位于同一目录中,或者位于 python 知道的子目录中。尝试将 dll 路径添加到 PATH 环境变量中。

于 2013-05-27T05:36:26.313 回答