CallDLL Package

Rajat Chopra rajat at cs.utexas.edu
Thu Apr 25 16:18:39 EDT 2002


Hi, 

I am attempting to build a python library (pyd file) for the CallDLL
package (http://www.nightmare.com/~rushing/dynwin/index.html) - which
allows you to dynamically load and call any function in a DLL - that
will run on the newest version of Python (v2.2).

I am using MinGW32 (particularly GCC and the BINUTILS package) to
rebuild the Python library file. When I run the script to rebuild the
library file, however,  I continuously get the error of "undefined
reference to LoadLibraryA, FreeLibrary, GetModuleHandleA, and
GetProcAddress functions".

I understand that these are Windows specific functions that are
contained in Kernel32.dll. However, as this is a critical DLL, I
believe it is directly linked to in the normal C compile. In fact,
when I did a verbose run of the script, I indeed saw that kernel32
(along with several other DLLs) are linked to automatically by GCC.

I am wondering what could cause this error. It is strange because when
I link to the Python DLL (python22.dll), the Linker resolves all the
function names referenced within that DLL without a problem. I am
placing the script I am running to build my python library below:

 -------
|SCRIPT |
 -------
gcc -I"C:\Program Files\Python\include" -O2 -c calldllmodule.c -o
calldllmodule.o

dllwrap --dllname calldll.pyd --driver-name gcc --def calldll.def -o
calldll.pyd calldllmodule.o -s --entry _DllMain at 12
--target=i386-mingw32
-L"C:\WINNT\system32" -lpython22 

(DLLWrap is a utility that is included in BINUTILS. I believe it is
equivalent to DLLTOOL).

Also, the verbose script shows the following libraries being linked to
by GCC (notice both python22 & kernel32 are linked to):
-python22 -lmingw32 -lgcc -lmoldname -lmsvcrt -luser32 -lkernel32
-ladvapi32
-lshell32 

Thank you in advance.

-Rajat



More information about the Python-list mailing list