Tcl:如何改变nameofexecutable的行为

时间:2013-05-27 05:22:50

标签: python tcl tk tix

我在使用python解释器的c可执行文件中遇到了一些问题。 由于某种原因,它无法加载<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 - &gt;没有变化
  3. 在调用PySys_SetArgv之前设置c可执行文件的argv[0] - &gt;没有变化
  4. 我做了些蠢事,或者如何设置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一些但不总是然后失败

2 个答案:

答案 0 :(得分:1)

{T}库初始化期间设置nameofexecutable属性(从Tcl_FindExecutable()的参数派生,我不知道究竟是怎么调用的,但绝对是:它用于做各种各样的的东西)。您无法在任何其他位置设置它。但是,Tcl实际上并没有使用那个你无法覆盖的值。

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

答案 1 :(得分:0)

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