(Python C-API) MSVC link: unresolved external symbols
Nicholas Fitzkee
nickfitzkee at jhu.edu
Tue Feb 4 15:07:11 EST 2003
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
_atom3d.c
_atom3d.c(192) : warning C4101: 'i' : unreferenced local variable
_atom3d.c(523) : warning C4101: 'ret' : unreferenced local variable
_atom3d.c(1002) : warning C4101: 'i' : unreferenced local variable
_atom3d.c(1110) : warning C4101: 'one' : unreferenced local variable
-- unsnip --
There's nothing surprising there. Note that _atom3d.c defines a new
python object. Also note that the include and library directories
are already listed in the various environment variables. The link
command I use is below:
-- snip --
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.
I am able to compile the Numeric python and psyco packages
just fine, with a few modifications made to the setup.py file.
I'm not a big Microsoft programmer, so I'd prefer to understand
how to do this without using the Visual C++ workspace given in
the python source tree. Not to be picky, though, I have tried
that route and gotten similar results.
Any help would be appreciated.
Thanks,
Nick
More information about the Python-list
mailing list