(Python C-API) MSVC link: unresolved external symbols

Thomas Heller theller at python.net
Tue Feb 4 21:47:56 CET 2003


nickfitzkee at jhu.edu (Nicholas Fitzkee) writes:

> Hello,
> 
> These types of messages seem to make it here alot, but hopefully
> this one will be resolved.  I am attempting to port a python
> module from linux (where it compiles/works fine) to MS Windows
> (98 SE, MS Visual C++ 6.0).  I am using the python-2.2.2 build.

> 
> Below is the command line I am using to compile:
> 
> -- snip --
> 
> cl.exe /c /nologo /Ox /MD /W3 /GX /D HAVE_NUMPY /D NDEBUG /D USE_DL_EXPORT
> /D WIN32 _atom3d.c 
> 
I would guess the USE_DL_EXPORT looks suspicious, but see below.

> link.exe /DLL /nologo /INCREMENTAL:NO python22.lib /EXPORT:init_atom3d 
> _atom3d.obj /OUT:_atom3d.pyd
> 
>  python22.lib /EXPORT:init_atom3d _atom3d.obj /OUT:_atom3d.pyd
>    Creating library _atom3d.lib and object _atom3d.exp
> _atom3d.obj : error LNK2001: unresolved external symbol _PyType_Type
> _atom3d.obj : error LNK2001: unresolved external symbol _PyExc_TypeError
> _atom3d.obj : error LNK2001: unresolved external symbol _PyLong_Type
> _atom3d.obj : error LNK2001: unresolved external symbol _PyInt_Type
> _atom3d.obj : error LNK2001: unresolved external symbol _PyFloat_Type
> _atom3d.obj : error LNK2001: unresolved external symbol _PyExc_ValueError
> _atom3d.obj : error LNK2001: unresolved external symbol _PyDict_Type
> _atom3d.obj : error LNK2001: unresolved external symbol __Py_NoneStruct
> _atom3d.obj : error LNK2001: unresolved external symbol _PyCObject_Type
> _atom3d.pyd : fatal error LNK1120: 9 unresolved externals
> 
> -- unsnip --
> 
> I'm not understanding why the linker cannot find the symbols
> given above.  Using "dumpbin" to examine python22.lib, it appears
> that all of those symbols are present in the library file.  I 
> can't figure out what I'm doing wrong such that link doesn't 
> see them.  Similar error messages come up when I use the intel 
> compiler.
> 
Here are some of the compiler and linker command lines for the _ctypes
extension:

C:\VC98\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX -IC:\python22\include /TcC:\sf\ctypes_head\source\callproc.c /Fobuild\temp.win32-2.2\Release\callproc.obj

C:\VC98\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\python22\libs ole32.lib /EXPORT:init_ctypes build\temp.win32-2.2\Release\_ctypes.obj build\temp.win32-2.2\Release\callbacks.obj build\temp.win32-2.2\Release\callproc.obj /OUT:build\lib.win32-2.2\_ctypes.pyd /IMPLIB:build\temp.win32-2.2\Release\_ctypes.lib

Maybe this is of some help to you.

But you should really, really write a setup script, and use distutils
to build your extension (even if you don't want to distribute it).

distutils automatically gets it right, setup.py is portable
between Windows, Linux, and other systems, and more...

Thomas




More information about the Python-list mailing list