Undefined Python references in g++

2019-04-29 03:52发布

I am using the following command:

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

And I am getting the following errors:

/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

Why isn't g++ recognizing libpython2.7.so? I checked out and it is located in /usr/lib.

标签: c++ linker g++
1条回答
\"骚年 ilove
2楼-- · 2019-04-29 04:40

The order of libraries on the link line matters, and your order is wrong.

查看更多
登录 后发表回答