Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Date: Thu, 27 Sep 2001 10:18:37 -0600 From: "Darrell R. Hougen" Subject: Problem linking python extensions To: cygwin AT cygwin DOT com Cc: darrell DOT r DOT hougen AT lmco DOT com Message-id: <3BB3515D.C01127D1@lmco.com> Organization: Myself MIME-version: 1.0 X-Mailer: Mozilla 4.76 [en] (WinNT; U) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Accept-Language: en Hi, I had thought that once I got my python extension to compile, my troubles would be few ... My extension does indeed compile, but I must not be building the dll correctly, because python can't seem to find the entry point. First, here are the error messages: When my dll is named TermObject.dll, I get: Python 2.1.1 (#2, Aug 23 2001, 10:41:44) [GCC 2.95.3-5 (cygwin special)] on cygwin ... >>> import TermObject Traceback (most recent call last): File "", line 1, in ? ImportError: dynamic module does not define init function (initTermObject) When my dll is named TermObject.pyd, I get: >>> import TermObject Traceback (most recent call last): File "", line 1, in ? ImportError: No module named TermObject In both cases, nm shows that TermObject.dll (or pyd) contains the line: 00402238 T _initTermObject The .defs file produced by dlltool looks like: ; dlltool --base-file TermObject.base --output-def TermObject.def --output-exp TermObject.exp --dllname TermObject.dll EXPORTS which, to me, looks like nothing is getting exported. The code looks like: DL_EXPORT(void) initTermObject(HANDLE h, DWORD reason, void *foo) { Py_InitModule("TermObject", TermObjectMethods); import_array(); } The makefile (which I got from the Cygwin user's guide) looks like: $(CC) -s -Wl,--base-file,TermObject.base -o TermObject.dll TermObject.o -Wl,-e,_initTermObject $(LDLIBS) $(DLLTOOL) --base-file TermObject.base --output-def TermObject.def --output-exp TermObject.exp --dllname TermObject.dll $(CC) -s -Wl,--base-file,TermObject.base,TermObject.exp -o TermObject.dll TermObject.o -Wl,-e,_initTermObject $(LDLIBS) $(DLLTOOL) --base-file TermObject.base --output-def TermObject.def --output-exp TermObject.exp --dllname TermObject.dll $(CC) -Wl,TermObject.exp -o TermObject.dll TermObject.o -Wl,-e,_initTermObject $(LDLIBS) Note that in the user's guide, _initTermObject is rendered _initTermObject AT 12, but the need for the @12 part seems to go away with the use of DL_EXPORT(void). I've tried it both ways. If I add the line: $(DLLTOOL) --output-def TermObject.def --dllname TermObject.dll --output-lib TermObject.dll I get the error message: >>> import TermObject Traceback (most recent call last): File "", line 1, in ? ImportError: dlopen: Win32 error 193 I have also tried a whole bunch of other permutations including using "int WINAPI", as suggested by the Cygwin user's guide, or "__declspec(dllexport)", as is done with windows apps, instead of "DL_EXPORT(void)" in my C code. If I try to follow the dlltool manpage and use asm directives, I wind up creating something that causes python to coredump. Any help is greatly appreciated. Thanks. Darrell -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/