Unresolved external characters building a Python C extension

I am currently trying to create a C extension on Windows. Errors, apparently, are related to the fact that they do not detect "standard" characters in the python27.dll file. How to resolve these missing characters? Do I need to somehow tell the compiler where to find python27.dll or something is wrong with my python27.lib?

My setup is this:

  • 64-bit version of Windows 7
  • Python 2.7.4
  • Numpy 1.7
  • Swig 2.0.9
  • Visual studio 9.0

I found this link, which seems to be related to the problem, but with versions of things that I don't use: http://bugs.python.org/issue15772

I run python setup.py build_ext --inplaceto create an extension.

The setup.py file is as follows:

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 the following communication command starts:

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

, Python :

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

Python, C: Python27\libs\python27.lib. , , , . , , , , . , dumpbin -headers C:\Python27\libs\python27.lib :

  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

, python27.lib , PyString_AsString python27.dll.

- , , ?

+4
1

python27.lib. dumpbin , 64 , , V++ - 32 .

+7

Source: https://habr.com/ru/post/1543131/


All Articles