2013-05-27 61 views
0

我對使用python解釋器的c可執行文件中的tcl有一些問題。 由於某些原因,它無法加載<fullpath>Tix843.dll。但是,直接運行python代碼(來自python)它確實有效。 dll的路徑/名稱是正確的... 與依賴沃克我只看到Tkinter試圖加載tix dll但無法找到它...Tcl:如何更改nameofexecutable的行爲

在tcl內跟蹤所有類型的路徑後,我只能檢測1個差異:nameofexecutable。當直接從python運行它是python.exe的路徑,但是從我的c可執行文件運行時,它顯然是path/name of the executable

在tcl/tk我注意到nameofexecutable用於設置很多路徑,所以我認爲這會導致我的問題。

的事情我試圖阻止這個問題:

  1. 的路徑添加到該dll到系統路徑
  2. 的路徑添加到該dll到​​- >無變化
  3. 設置argv[0]調用PySys_SetArgv之前的c可執行文件 - >沒有變化

我在做一些愚蠢的事情,或者我該如何設置nameofexecutable?有沒有其他方法可以解決這個問題。

編輯: 用的Dependency 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有時但並不總是和然後失敗

回答

0

很可能,C程序找不到Tix.dll,因爲它不在您的路徑中。 Python可以找到它,因爲它與python可執行文件位於同一目錄中,或者位於python知道的子目錄中。嘗試將dll路徑添加到PATH環境變量中。

+0

對不起,忘記提及,我嘗試過,但沒有成功......它實際上給了DLL的正確路徑,並表示它不能加載它(或依賴庫...)我檢查與依賴沃克,但只說Tkinter不能加載 Tix.dll ...所以不知道如何解決這個問題 – Jen

1

nameofexecutable屬性在Tcl庫初始化期間設置(從參數導出到Tcl_FindExecutable(),我不知道如何被調用,但肯定是:它用來做各種各樣的東西)。您無法在任何其他位置設置它。但是,Tcl並沒有真正使用這個值,你不能重載。

相反,你應該看看TCLLIBPATH環境變量設置爲目錄的Tcl列表中搜索包的定義。或者你也可以到auto_path全局變量裏面添加含有實際的Tcl(與lappend auto_path)目錄要查看的地方列表(好吧,它實際上也查找該變量中列出的地點的直接子目錄)。這當然是在你嘗試加載Tix之前完成的。