2016-07-07 101 views
0

我嘗試使用swig編譯python 2.7中的C++代碼包裝。 (如果錯誤,請糾正我的表述)。此代碼用於在另一臺計算機上工作,並且所有庫(尤其是-lpython27)都位於它們應該在的位置,它們分別代表它們應該在的位置:連接python lib與swig和g ++的錯誤

PATH變量包括(除其他外):「C:\ Python27 \ Lib \ site-packages; C:\ Python27 \庫; C:\ Python27; C:\ MinGW的\ BIN」

PYTHONPATH包括:C:\ Python27; C:\ Python27 \ LIB \站點包

我編譯:

swig.exe -c++ -python test8.i 
g++.exe -c -Wall test8.cpp 
g++.exe -c -Wall test8_wrap.cxx -I C:\Python27\include -I C:\Python27\Lib\site-packages\numpy\core\include\ 2> log_file2.txt 
g++.exe -Wall -shared -I C:\Python27\include -I C:\Python27\Lib\site-packages\numpy\core\include\ -L C:\Python27\libs\ -lpython27 test8.o test8_wrap.o -o _Amod.pyd 2> log_file3.txt 

我認爲3條第一行編譯正確,因爲我得到了test8.o和test8_wrap.o作爲輸出。但最後一行未輸出庫_Amod.pyd和我得到的錯誤:

g++.exe : test8_wrap.o:test8_wrap.cxx:(.text+0x8fd): undefined reference to `_imp__PyString_AsString' 
Au niveau de C:\Users\mollica\Documents\Python\Py_Proj\test8_spy\compile_swig_script8_win.ps1 : 5 Caractère : 8 
+ g++.exe <<<< -Wall -shared -I C:\Python27\include -I C:\Python27\Lib\site-packages\numpy\core\include\ -L C:\Python 
27\libs\ -lpython27 test8.o test8_wrap.o -o _Amod.pyd 2> log_file3.txt 
    + CategoryInfo   : NotSpecified: (test8_wrap.o:te...tring_AsString':String) [], RemoteException 
    + FullyQualifiedErrorId : NativeCommandError 

test8_wrap.o:test8_wrap.cxx:(.text+0x912): undefined reference to 
`_imp__PyString_FromString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x940): undefined reference to `_imp__PyExc_MemoryError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x94f): undefined reference to `_imp__PyExc_IOError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x95b): undefined reference to `_imp__PyExc_RuntimeError 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x967): undefined reference to `_imp__PyExc_IndexError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x973): undefined reference 
to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x97f): undefined reference 
to `_imp__PyExc_ZeroDivisionError' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x98b): undefined reference to 
`_imp__PyExc_OverflowError' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x997): undefined 
reference to `_imp__PyExc_SyntaxError 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x9a3): undefined reference to `_imp__PyExc_ValueError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x9af): undefined reference to `_imp__PyExc_SystemError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x9bb): undefined reference to `_imp__PyExc_AttributeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x9c7): undefined reference to `_imp__PyExc_RuntimeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x9f1): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0xa15): undefined reference to `_imp__PyErr_Fetch' 
test8_wrap.o:test8_wrap.cxx:(.text+0xa2d): undefined 
reference to `_imp__PyObject_Str' 
test8_wrap.o:test8_wrap.cxx:(.text+0xa37): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0xa79): undefined 
reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0xad6): undefined 
reference to `_imp__PyExc_RuntimeError 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0xae7): undefined reference 
to `_imp__PyErr_SetString' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0xb0d): undefined 
reference to `_imp__PyErr_SetObject 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0xb55): undefined reference to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.text+0xb78): undefined reference to `_imp__PyDict_SetItemString' 
test8_wrap.o:test8_wrap.cxx:(.text+0xbc4): undefined reference to `_imp___Py_NoneStruct' 
test8_wrap.o:test8_wrap.cxx:(.text+0xc24): undefined reference to `_imp__PyList_New' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0xc43): undefined reference to 
`_imp__PyList_SetItem' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0xc57): undefined 
reference to `_imp__PyList_Append 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0xcc5): undefined reference to 
`_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0xce9): undefined reference to `_imp__PyErr_Format 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0xd54): undefined reference 
to `_imp__PyExc_SystemError' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0xd66 
): undefined reference to 
`_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0xd9c): undefined 
reference to `_imp__PyExc_TypeError' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0xdc7): undefined reference to 
`_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0xdf4): undefined reference to `_imp__PyExc_TypeError 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0xe1f): undefined reference 
to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0xe96): undefined 
reference to `_imp__Py_BuildValue 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0xfa0): undefined reference to `_imp__PyClass_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0xfde): undefined reference to `_imp__PyObject_GetAttrString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x100b): undefined reference to `_imp__PyTuple_New' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1032 
): undefined reference to 
`_imp__PyTuple_SetItem' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x1061): undefined 
reference to `_imp__PyObject_GetAttrString' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1070): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x1080): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x11b2 
): undefined reference to 
`_imp__PyLong_FromVoidPtr 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x11cf): undefined reference 
to `_imp__PyTuple_New' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1200 
): undefined reference to 
`_imp__PyTuple_SetItem' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x1235): undefined reference to `_imp__PyString_Format 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x130d): undefined reference to `_imp__PyString_FromFormat' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x133f): undefined reference to `_imp__PyString_ConcatAndDel 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x139a): undefined reference to `_imp___Py_NotImplementedStruct' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x13a4): undefined reference to `_imp___Py_NotImplementedStruct 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x13ab): undefined reference to `_imp___Py_NotImplementedStruct' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x13e5): undefined reference to 
`_imp__PyBool_FromLong' 
test8_wrap.o:test8_wrap.cxx:(.text+0x154e): undefined 
reference to `_imp__PyObject_CallFunctionObjArgs 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x1650): undefined reference 
to `_imp__PyObject_Free' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x173b 
): undefined reference to 
`_imp__PyArg_UnpackTuple' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x1761): undefined reference 
to `_imp__PyBool_FromLong' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1778 
): undefined reference to 
`_imp__PyObject_IsTrue' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x17fb): undefined reference to `_imp__PyType_Ready 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x1839): undefined reference 
to `_imp__PyObject_Malloc' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1847 
): undefined reference to 
`_imp__PyObject_Init' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x19b6): undefined reference to `_imp__PyString_FromFormat 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x19d2 
): undefined reference to 
`_imp__PyString_FromFormat' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x1a3c): undefined reference to `_imp__PyString_FromFormat 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x1bb3): undefined reference to `_imp__PyObject_Free' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1c39): undefined 
reference to `_imp__PyObject_GenericGetAttr 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1c81): undefined reference 
to `_imp__PyType_Ready' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1cbf): undefined reference to 
`_imp__PyObject_Malloc' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1ccd): undefined reference to `_imp__PyObject_Init 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1d2d): undefined reference to `_imp__PyObject_Free' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x1e04): undefined reference to `_imp__PyInstance_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1e1c 
): undefined reference to `_imp___PyInstance_Lookup 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1e31): undefined reference 
to `_imp___PyObject_GetDictPtr' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1e5e 
): undefined reference to `_imp__PyDict_GetItem 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1e7a): undefined reference 
to `_imp___PyWeakref_ProxyType' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1e89 
): undefined reference to 
`_imp___PyWeakref_CallableProxyType' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x1edd): undefined reference to `_imp__PyObject_GetAttr 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x1f1b): undefined reference 
to `_imp__PyErr_Occurred' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x1f2b): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0x21c7): undefined reference to `_imp__PyObject_CallFunctionObjArgs' 
test8_wrap.o:test8_wrap.cxx:(.text+0x21db): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x21eb): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0x22d2): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x22e2): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x2301): undefined reference to `_imp__PyCFunction_Type' 
test8_wrap.o 
:test8_wrap.cxx:(.text+0x24d1): undefined 
reference to `_imp__PyObject_Call 
' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x24e7): undefined reference to 
`_imp___PyObject_GetDictPtr' 
test8_wrap.o:test8_wrap.cxx 
:(.text 
+0x2505 
): undefined reference to `_imp__PyDict_New' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x252f): undefined reference to `_imp__PyDict_SetItem 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2538): undefined reference to `_imp__PyDict_New 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2560): undefined reference 
to `_imp__PyDict_SetItem' 
test8_wrap.o:test8_wrap.cxx 
:(.text+0x2577): undefined 
reference to `_imp__PyInstance_NewRaw 
' 
test8_wrap.o:test8_wrap.cxx:(.text+0x25be): undefined reference to `_imp___PyObject_GetDictPtr' 
test8_wrap.o:test8_wrap.cxx:(.text+0x25dc): undefined reference to `_imp__PyDict_New' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2606): undefined reference to `_imp__PyDict_SetItem' 
test8_wrap.o:test8_wrap.cxx:(.text+0x261d): undefined reference to `_imp__PyObject_GetAttrString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x263f): undefined reference to `_imp__PyDict_SetItem' 
test8_wrap.o:test8_wrap.cxx:(.text+0x27ad): undefined reference to `_imp___PyObject_New' 
test8_wrap.o:test8_wrap.cxx:(.text+0x28e4): undefined reference to `_imp__PyCapsule_Import' 
test8_wrap.o:test8_wrap.cxx:(.text+0x28f0): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2900): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0x292d): undefined reference to `_imp__PyCapsule_GetPointer' 
test8_wrap.o:test8_wrap.cxx:(.text+0x29f8): undefined reference to `_imp__Py_InitModule4' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2a18): undefined reference to `_imp__PyCapsule_New' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2a43): undefined reference to `_imp__PyModule_AddObject' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2aae): undefined reference to `_imp__PyDict_New' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2b1b): undefined reference to `_imp__PyDict_GetItem' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2b39): undefined reference to `_imp__PyCapsule_GetPointer' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2b8f): undefined reference to `_imp__PyCapsule_New' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2bad): undefined reference to `_imp__PyDict_SetItem' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2c17): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2c54): undefined reference to `_imp__PyErr_Fetch' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2c6c): undefined reference to `_imp__PyObject_Str' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2c87): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2cbe): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2cf1): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2d3d): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2d6d): undefined reference to `_imp__PyOS_snprintf' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2dcc): undefined reference to `_imp__PyObject_Str' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2df7): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2e1e): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2e27): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2e47): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2e84): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2e9d): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2ea6): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2eb8): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2ef9): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2f12): undefined reference to `_imp__PyImport_ImportModule' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2f29): undefined reference to `_imp__PyExc_ImportError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2f3b): undefined reference to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2f5a): undefined reference to `_imp__PyObject_GetAttrString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2f96): undefined reference to `_imp__PyExc_AttributeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2fa8): undefined reference to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2fbf): undefined reference to `_imp__PyCObject_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2fc8): undefined reference to `_imp__PyExc_RuntimeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x2fda): undefined reference 
to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x301d): undefined reference to `_imp__PyCObject_AsVoidPtr' 
test8_wrap.o:test8_wrap.cxx:(.text+0x305e): undefined reference to `_imp__PyExc_RuntimeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3070): undefined reference to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x30a1): undefined reference to `_imp__PyExc_RuntimeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x30bf): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x30f8): undefined reference to `_imp__PyExc_RuntimeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3116): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x313b): undefined reference to `_imp__PyExc_RuntimeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x314d): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3161): undefined reference to `_imp__PyExc_RuntimeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3173): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3196): undefined reference to `_imp__PyExc_ValueError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x31b6): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x322b): undefined reference to `_imp__PyCallable_Check' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3283): undefined reference to `_imp__PyFloat_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3293): undefined reference to `_imp__PyFloat_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x329f): undefined reference to `_imp__PyType_IsSubtype' 
test8_wrap.o:test8_wrap.cxx:(.text+0x331e): undefined reference to 
`_imp__PyFile_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x332e): undefined reference to `_imp__PyFile_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x333a): undefined reference to `_imp__PyType_IsSubtype' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3362): undefined reference to `_imp__PyModule_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3372): undefined reference to `_imp__PyModule_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x337e): undefined reference to `_imp__PyType_IsSubtype' 
test8_wrap.o:test8_wrap.cxx:(.text+0x33a6): undefined reference to `_imp__PyInstance_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x343f): undefined reference to `_imp__PyType_IsSubtype' 
test8_wrap.o:test8_wrap.cxx:(.text+0x34c3): undefined reference to `_imp__PyType_IsSubtype' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3500): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3520): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x354c): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x356c): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x35be): undefined reference to `_imp__PyType_IsSubtype' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3927): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3939): undefined reference to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3967): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3979): undefined reference to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x39aa): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x39c7): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3b12): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3b32): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3d39): undefined reference to `_imp__PyExc_TypeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3d5f): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3e41): undefined reference to `_imp__PyFloat_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3e51): undefined reference to `_imp__PyFloat_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3e5d): undefined reference to `_imp__PyType_IsSubtype' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3e84): undefined reference to `_imp__PyFloat_AsDouble' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3eb8): undefined reference to `_imp__PyInt_AsLong' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3ee9): undefined reference to `_imp__PyLong_AsDouble' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3ef3): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3f18): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3f48): undefined reference to `_imp__PyInt_AsLong' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3f75): undefined reference to `_imp__PyLong_AsLong' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3f7f): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3fa4): undefined reference to `_imp__PyErr_Clear' 
test8_wrap.o:test8_wrap.cxx:(.text+0x3ffc): undefined reference to `_imp__PyExc_ValueError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x402a): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x40a5): undefined reference to `_imp__PyExc_ValueError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x40d3): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x4135): undefined reference to `_imp__PyBool_Type' 
test8_wrap.o:test8_wrap.cxx:(.text+0x414b): undefined reference to `_imp__PyObject_IsTrue' 
test8_wrap.o:test8_wrap.cxx:(.text+0x4191): undefined reference to `_imp__PyExc_ValueError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x41b8): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x42a7): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x4534): undefined reference to `_imp__P 
yErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x460b): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x48ed): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x4a25): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x4dc9): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x4e73): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x51a5): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5573): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5888): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5957): undefined reference to `_imp__PyArg_ParseTuple' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5d5d): undefined reference to `_imp__PyString_FromString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5d73): undefined reference to `_imp__PyString_FromString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5d90): undefined reference to `_imp__PyString_FromString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5da1): undefined reference to `_imp__PyString_ConcatAndDel' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5db9): undefined reference to `_imp__PyString_FromString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5dca): undefined reference to `_imp__PyString_ConcatAndDel' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5de7): undefined reference to `_imp__PyString_FromString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5df8): undefined reference to `_imp__PyString_ConcatAndDel' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5f28): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5f43): undefined reference to `_imp__PyExc_AttributeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5f5c): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5fc0): undefined reference to `_imp__PyErr_Occurred' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5fdb): undefined reference to `_imp__PyExc_AttributeError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x5ff4): undefined reference to `_imp__PyErr_Format' 
test8_wrap.o:test8_wrap.cxx:(.text+0x60ba): undefined reference to `_imp__PyType_Ready' 
test8_wrap.o:test8_wrap.cxx:(.text+0x60f8): undefined reference to `_imp__PyObject_Malloc' 
test8_wrap.o:test8_wrap.cxx:(.text 
+0x6106): undefined reference to `_imp__PyObject_Init' 
test8_wrap.o:test8_wrap.cxx:(.text+0x62cd): undefined reference to `_imp__PyDict_SetItemString' 
test8_wrap.o:test8_wrap.cxx:(.text+0x6597): undefined reference to `_imp__Py_InitModule4' 
test8_wrap.o:test8_wrap.cxx:(.text+0x65a7): undefined reference to `_imp__PyModule_GetDict' 
test8_wrap.o:test8_wrap.cxx:(.text+0x65e2): undefined reference to `_imp__PyErr_Print' 
test8_wrap.o:test8_wrap.cxx:(.text+0x65e9): undefined reference to `_imp__PyExc_ImportError' 
test8_wrap.o:test8_wrap.cxx:(.text+0x65fb): undefined reference to `_imp__PyErr_SetString' 
test8_wrap.o:test8_wrap.cxx:(.data+0xc8): undefined reference to `PyObject_GenericGetAttr 
' 
collect2.exe: error: ld returned 1 exit status 

通過環顧四周,似乎這些錯誤來自的-lpython27壞鏈接。但在我的情況下,它包含正確,所以我不知道我在哪裏錯過了什麼。 64位與32位的問題?我如何檢查?

親切的問候,

F.M.

+0

您可以嘗試按照[此答案](http://stackoverflow.com/a/34934865/5781248) –

回答

1

將最後一個編譯行上的.o文件後面的-lpython27移開。 python27庫被加載,然後不需要依賴關係,因爲.o文件沒有被查看,所以符號不被保留。請參閱Why does the order in which libraries are linked sometimes cause errors in GCC?

+0

中的說明生成'libpython27.dll.a'我相信你是對的。 –

+0

我剛剛嘗試過,但它升起了完全相同的錯誤。 –

+0

您是否可以共享您的.cpp代碼樣本,以便我可以嘗試在我的機器上進行編譯? – Alden