I'm currently trying to build a C-extension in Windows. The errors seem related to not finding 'standard' symbols in the python27.dll. How do I resolve these missing symbols? Do I need to somehow tell the compiler where to find python27.dll or is something wrong with my python27.lib?
My setup is the following:
I found this link that seems to have a related problem, but with versions of things I'm not using: http://bugs.python.org/issue15772
I'm running python setup.py build_ext --inplace
to build the extension.
The setup.py looks like the following:
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
fmm3d_module = Extension('_fmm3d', sources=['fmm3d.i', 'fmm3d.c'],
include_dirs = [numpy_include])
Everything compiles fine and then runs the following link command:
C:\Program Files (x86)\Microsoft Visual Studio 9.\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\ amd64 /EXPORT:init_fmm3d build\temp.win-amd64-2.7\Release\fmm3d_wrap.obj build\temp.win-amd64-2.7\Release\fmm3d.obj /OUT:C:\Users\luke\Documents\Ranking\code\_fmm3d.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\_fmm3d.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\_fmm3d.pyd.manifest
I get link errors that relate to Python symbols like the following:
fmm3d_wrap.obj : error LNK2019: unresolved external symbol __imp__PyString_AsString referenced in function _SWIG_Python_str_AsChar
fmm3d_wrap.obj : error LNK2019: unresolved external symbol __imp__PyString_FromString referenced in function _SWIG_Python_str_FromChar
fmm3d_wrap.obj : error LNK2019: unresolved external symbol __imp__PyExc_RuntimeError referenced in function _SWIG_Python_ErrorType
fmm3d_wrap.obj : error LNK2019: unresolved external symbol __imp__PyExc_AttributeError referenced in function _SWIG_Python_ErrorType
I've found the Python lib file located at C:Python27\libs\python27.lib. I assume the symbols are expected to be in here. In fact, it looks like they are at least referenced in this file. For example, running dumpbin -headers C:\Python27\libs\python27.lib
shows the following snippet:
Version : 0
Machine : 8664 (x64)
TimeDateStamp: 5160619D Sat Apr 06 12:55:41 2013
SizeOfData : 0000001F
DLL name : python27.dll
Symbol name : PyString_AsString
Type : code
Name type : name
Hint : 629
Name : PyString_AsString
This leads me to believe that the python27.lib says the reference for PyString_AsString is contained in python27.dll.
Is there some other command-line argument I'm missing to locate these symbols?
There should be a python27.lib on the command line. Your dumpbin indicates your python is 64 bit, probably your VC++ compiler is 32 bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With