2013-05-05 225 views
5

我使用下面的命令:未定義的Python引用++

g++ -L/usr/lib/panda3d -L/usr/lib -o "panda3dplayground" ./main.o -lpython2.7 -lp3pystub -lp3framework -lpandafx -lp3pystub -lpandaexpress -lpanda -lp3framework -lp3direct 

而且我收到以下錯誤:

/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_Cmp' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyUnicodeUCS4_FromWideChar' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyDict_SetItem' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_ValueError' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyDict_SetItemString' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyType_IsSubtype' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyString_FromString' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_Fetch' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_StandardError' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyInt_AsSsize_t' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyArg_Parse' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyEval_RestoreThread' 
/usr/lib/panda3d/libpandaexpress.so: undefined reference to `PyString_AsStringAndSize' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_CallFunction' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyDict_Size' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyString_Size' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_Print' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_SetString' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyGILState_Ensure' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_CallObject' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyString_FromStringAndSize' 
/usr/lib/panda3d/libp3dtool.so: undefined reference to `PySys_GetObject' 
/usr/lib/panda3d/libp3dtool.so: undefined reference to `PyList_GetItem' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_AssertionError' 
/usr/lib/panda3d/libp3dtoolconfig.so: undefined reference to `Py_InitModule4_64' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyModule_AddStringConstant' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyGen_Type' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_Compare' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyList_Append' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyMapping_GetItemString' 
/usr/lib/panda3d/libp3dtoolconfig.so: undefined reference to `PyArg_ParseTuple' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyTuple_Pack' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyLong_FromUnsignedLongLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_Repr' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyInt_FromLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyArg_ParseTupleAndKeywords' 
/usr/lib/panda3d/libpanda.so: undefined reference to `_Py_NoneStruct' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyList_SetItem' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyCallable_Check' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_Clear' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyLong_AsUnsignedLongLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_ExceptionMatches' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyDict_New' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyUnicodeUCS4_AsWideChar' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyInt_AsLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyUnicodeUCS4_GetSize' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_RichCompareBool' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyModule_AddObject' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyGILState_Release' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PySequence_GetItem' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyLong_AsUnsignedLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `_Py_NotImplementedStruct' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PySequence_Size' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_TypeError' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyNumber_Long' 
/usr/lib/panda3d/libpanda.so: undefined reference to `Py_BuildValue' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyEval_InitThreads' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyType_Ready' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyFloat_FromDouble' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_GenericSetAttr' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_IsTrue' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyImport_GetModuleDict' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_Free' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyNumber_Float' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyBool_FromLong' 
/usr/lib/panda3d/libp3dtoolconfig.so: undefined reference to `PyLong_AsLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_IndexError' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyLong_AsLongLong' 
/usr/lib/panda3d/libpandaexpress.so: undefined reference to `PyLong_FromLongLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyFloat_AsDouble' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyEval_SaveThread' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_Restore' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_WarnEx' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyString_Type' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_StopIteration' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_Type' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_Call' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PySequence_Check' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyType_GenericAlloc' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyString_AsString' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyModule_AddIntConstant' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_CallMethod' 
/usr/lib/panda3d/libp3dtool.so: undefined reference to `Py_IsInitialized' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_GetAttrString' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyList_New' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_SystemExit' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyDict_GetItem' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_FutureWarning' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyTuple_New' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_Format' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyCFunction_NewEx' 
/usr/lib/panda3d/libp3dtoolconfig.so: undefined reference to `PyLong_FromUnsignedLong' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_AttributeError' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_GenericGetAttr' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyTuple_Size' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PySequence_Fast' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyErr_Occurred' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PySequence_Tuple' 
/usr/lib/panda3d/libpanda.so: undefined reference to `PyDict_DelItemString' 
collect2: error: ld returned 1 exit status 

爲什麼不是G ++承認libpython2.7.so?我檢查出它位於/usr/lib

+1

鏈接順序很重要。移動'-lpython2.7',以便它在缺失某些函數的所有庫之後出現。 – Mat 2013-05-05 07:43:03

+0

檢查'libpython'(x86/x64)的體系結構是否與程序其餘部分的體系結構相匹配 – 2013-05-05 07:45:49

+0

@ n.m。是的,它匹配(x86-64) – Pacha 2013-05-05 07:55:56

回答

4

鏈接行matters上的庫的順序,您的訂單是錯誤的。