In the past two days, I tried to use C to expand Python. It went very smoothly in Ubuntu and it was not blocked.
In Windows, I directly use VC to do what I said on a blog (create a DLL Project). As a result, a bunch of symbols cannot be found:
_ Imp _ Py_BuildValue
But I'm sure I have set the library directory and the included directory correctly.
Give up VC. I can use the setup. py method to compile it.
The result is that the symbols such as _ imp _ xxx are okay, but the other library I use has a problem and I keep prompting that the xx symbol cannot be found:
I'm sure I have already set the relevant lib path in setup. py. This problem should not occur. The content of my setup. py is as follows:
from distutils.core import setup,Extensionmodule1 = Extension(name = 'pyNV', sources = ['pyNV.c'], define_macros = [('QLIB_STATIC', None)])setup(name = 'pyNV', version = '1.0', description = 'NV operation python extention', ext_modules = [module1])
Related lib import code has been added to the Code:
#include "QLib.h"#include "QLib_Defines.h"#pragma comment( lib, "QMSL_MSVC9R.lib" )
But I am prompted that the XX symbol cannot be found. The XX symbol has been defined in Qlib. h, and it is also confirmed in lib. What is the problem ....
Then Google and Baidu won't be resolved...
Then notice that the build file generated by setup. py contains the following content: lib. amd64-2.7
It seems that something is wrong, my system is Win7-64bit, python is also python2.7-amd64, but QMSL_MSVC9R.lib seems to be a 32-bit version, ah, by, troubled me two days of the problem is so ???
Uninstall python2.7-amd64, re-download a 32bit version of python2.7, and run python setup build again!
C: \ Users \ Administrator \ Desktop \ pyNV> python setup. py buildrunning build_extbuilding 'pynv 'extensionC: \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ VC \ BIN \ cl.exe/c/nologo/Ox/MD/W3/GS-/DNDEBUG-DQLIB_STATIC-IC: \ Python27 \ include-IC: \ Python27 \ PC/TcpyNV. c/Fobuild \ temp. win32-2.7 \ Release \ pyNV. objpyNV. cC: \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ VC \ BIN \ link.exe/DLL/nologo/INCREMENTAL: NO/LIBPATH: C: \ Python27 \ libs/LIBPATH: c: \ Python27 \ PCbuild/EXPORT: initpyNV build \ temp. win32-2.7 \ Release \ pyNV. obj/OUT: build \ lib. win32-2.7 \ pyNV. pyd/IMPLIB: build \ temp. win32-2.7 \ Release \ pyNV. lib/MANIFESTFILE: build \ temp. win32-2.7 \ Release \ pyNV. pyd. manifest is creating Library build \ temp. win32-2.7 \ Release \ pyNV. lib and object build \ temp. win32-2.7 \ Release \ pyNV. exp
It seems that it is indeed because of library incompatibility issues that cannot find the symbol error.
You can use setup. during py compilation, you can check the compilation command. If the 64-bit compiler is used to generate 64-bit extensions, then the library file called by your C program should be 64-bit, as for whether to call 32bit, I have no time to go further.
I hope this information will be equally confusing to you.