0

I try the compilation of a wrapper of c++ code in python 2.7 with SWIG. (Please correct my formulation if wrong). This code uses to work on another machine, and all libraries (especially -lpython27) stand where they should be,

PATH variables include (among others) : "C:\Python27\Lib\site-packages;C:\Python27\libs;C:\Python27;C:\MinGW\bin"

PYTHONPATH includes : C:\Python27;C:\Python27\Lib\site-packages

I compile with :

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

I think the 3 first lines compile correctly, because I got test8.o and test8_wrap.o as output. But the last line fails to output the library _Amod.pyd and I get the error :

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

By looking around it seems that these errors come from the bad linking of -lpython27. But in my case, it's correctly included so I don't see where do I miss something. 64bits vs 32bits problem ? how can I check that ?

Kind regards,

F.M.

Florian M.
  • 301
  • 3
  • 15
  • You could try generating `libpython27.dll.a` following the instructions in [this answer](http://stackoverflow.com/a/34934865/5781248) – J.J. Hakala Jul 12 '16 at 09:26

1 Answers1

1

Move the -lpython27 after the .o files on the last compile line. The python27 library is loaded and then no dependencies are required because the .o files have not been looked at, so the symbols are not retained. See Why does the order in which libraries are linked sometimes cause errors in GCC?

Community
  • 1
  • 1
Alden
  • 2,229
  • 1
  • 15
  • 21
  • Are you able to share a sample of your .cpp code so I can try to compile on my machine? – Alden Jul 08 '16 at 14:14
  • Unfortunately not, I must build a simple "hello world" (or "hello numpy array" here) example first. I come back to the forum after. – Florian M. Jul 11 '16 at 12:32