0

i have some issues with tcl from a c executable using the python interpreter. For some reason it can't load the <fullpath>Tix843.dll. But when running the python code directly (from python) it does work. The path/name to the dll is correct... with a dependency walker i only see that Tkinter tries to load the tix dll but cant find it...

After tracing all kind of paths within tcl I can only detect 1 difference: nameofexecutable. When running directly from python it's the path to python.exe but when running it from my c executable it is (obviously) the path/name of the executable.

In tcl/tk I noticed that the nameofexecutable is used to set a lot of paths so i think this causes my problem.

The things i tried to prevent this problem:

  1. add the path to the dll to the system path
  2. add the path to the dll to $auto_path -> no change
  3. set the argv[0] of the c executable before calling PySys_SetArgv -> no change

Am I doing something stupid or how can I set the nameofexecutable? Is there any other way to fix this issue.

edit: checked again with the dependency walker and now i have relay no clue whats going on... here the results:

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.

so it can find the dlls some times but not always and then fails

Jen
  • 1
  • 1

2 Answers2

1

The nameofexecutable property is set during the Tcl library initialization (derived from the argument to Tcl_FindExecutable() which I don't know how exactly is being called, but definitely is: it's used to do all sorts of stuff). You can't set it at any other point. However, Tcl does not actually use that value for very much that you can't override.

Instead, you should look into setting the TCLLIBPATH environment variable to a Tcl list of directories to search for package definitions in. Or you can add directories to the auto_path global variable inside Tcl (with lappend auto_path) which contains the actual list of places to look (well, it actually looks in immediate subdirectories of the places listed in that variable as well). This has to be done before you try to load Tix, of course.

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
0

Most likely, the C program cannot find Tix.dll because it is not in your path. Python can find it because it is in the same directory as the python executable, or in a subdirectory that python knows about. Try adding the dll path to your PATH environment variable.

Markku K.
  • 3,840
  • 19
  • 20
  • sorry forgot to mention, i did try that but with no success... it actually gives the correct path to the dll and says it cant load it (or a dependent library...) i checked with the dependency walker but that only says that Tkinter cant load the Tix.dll... so no idea how to fix this – Jen May 27 '13 at 08:50