这是编译过程中遇到的问题。主要目的是使用 cython 编译从 python 生成的 c 文件。我是否还需要包含其他链接库或任何建议的方法才能编译好?
paultsai@paultsai-virtual-machine:~/cython/ex2$ gcc -Wall -I/usr/include/python3.5/ -lpython3.5 -L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/ -o prime_numbers_2 prime_numbers_2.c
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: in
function _start: (.text+0x20): undefined reference to「main」
/tmp/ccgBhADM.o: in function __Pyx_PyObject_GetAttrStr:
prime_numbers_2.c:(.text+0x61): undefined reference
to「PyObject_GetAttr」 /tmp/ccgBhADM.o: in function
__pyx_pf_15prime_numbers_2_is_prime: prime_numbers_2.c:(.text+0xf2): undefined reference to「PyTuple_New」 prime_numbers_2.c:(.text+0x24b):
undefined reference to「PyList_Type」 prime_numbers_2.c:(.text+0x267):
undefined reference to「PyTuple_Type」 prime_numbers_2.c:(.text+0x2c4):
undefined reference to「PyObject_GetIter」
prime_numbers_2.c:(.text+0x3db): undefined reference to「PyList_Type」
prime_numbers_2.c:(.text+0x4d7): undefined reference
to「PyErr_Occurred」 prime_numbers_2.c:(.text+0x4f3): undefined
reference to「PyExc_StopIteration」 prime_numbers_2.c:(.text+0x50c):
undefined reference to「PyExc_StopIteration」
prime_numbers_2.c:(.text+0x51e): undefined reference
to「PyErr_GivenExceptionMatches」 prime_numbers_2.c:(.text+0x530):
undefined reference to「PyErr_Clear」 prime_numbers_2.c:(.text+0x604):
undefined reference to「PyNumber_Remainder」
prime_numbers_2.c:(.text+0x7f6): undefined reference
to「_Py_FalseStruct」 prime_numbers_2.c:(.text+0x80b): undefined
reference to「_Py_FalseStruct」 prime_numbers_2.c:(.text+0x8ab):
undefined reference to「_Py_TrueStruct」
prime_numbers_2.c:(.text+0x8c0): undefined reference
to「_Py_TrueStruct」 prime_numbers_2.c:(.text+0x969): undefined
reference to「_Py_NoneStruct」 prime_numbers_2.c:(.text+0x970):
undefined reference to「_Py_NoneStruct」
prime_numbers_2.c:(.text+0x97b): undefined reference
to「_Py_NoneStruct」 /tmp/ccgBhADM.o: in function
__Pyx_InitCachedConstants: prime_numbers_2.c:(.text+0xb62): undefined reference to「PyTuple_Pack」 prime_numbers_2.c:(.text+0xc17): undefined
reference to「PyCode_New」 /tmp/ccgBhADM.o: in function
__Pyx_InitGlobals: prime_numbers_2.c:(.text+0xcac): undefined reference to「PyLong_FromLong」 prime_numbers_2.c:(.text+0xcf6):
undefined reference to「PyLong_FromLong」 /tmp/ccgBhADM.o: in function
PyInit_prime_numbers_2: prime_numbers_2.c:(.text+0xd8e): undefined
reference to「PyTuple_New」 prime_numbers_2.c:(.text+0xde0): undefined
reference to「PyBytes_FromStringAndSize」
prime_numbers_2.c:(.text+0xe32): undefined reference
to「PyUnicode_FromStringAndSize」 prime_numbers_2.c:(.text+0xe84):
undefined reference to「PyModule_Create2」
prime_numbers_2.c:(.text+0xed6): undefined reference
to「PyModule_GetDict」 prime_numbers_2.c:(.text+0xf34): undefined
reference to「PyImport_AddModule」 prime_numbers_2.c:(.text+0xf92):
undefined reference to「PyObject_SetAttrString」
prime_numbers_2.c:(.text+0x1012): undefined reference
to「PyObject_SetAttrString」 prime_numbers_2.c:(.text+0x1042): undefined
reference to「PyImport_GetModuleDict」 prime_numbers_2.c:(.text+0x108e):
undefined reference to「PyDict_GetItemString」
prime_numbers_2.c:(.text+0x10ab): undefined reference
to「PyDict_SetItemString」 prime_numbers_2.c:(.text+0x1156): undefined
reference to「PyCFunction_NewEx」 prime_numbers_2.c:(.text+0x11ae):
undefined reference to「PyDict_SetItem」
prime_numbers_2.c:(.text+0x1221): undefined reference to「PyDict_New」
prime_numbers_2.c:(.text+0x1279): undefined reference
to「PyDict_SetItem」 prime_numbers_2.c:(.text+0x13ba): undefined
reference to「PyErr_Occurred」 prime_numbers_2.c:(.text+0x13c6):
undefined reference to「PyExc_ImportError」
prime_numbers_2.c:(.text+0x13d3): undefined reference
to「PyErr_SetString」 /tmp/ccgBhADM.o: in function __Pyx_GetBuiltinName:
prime_numbers_2.c:(.text+0x1419): undefined reference
to「PyExc_NameError」 prime_numbers_2.c:(.text+0x142f): undefined
reference to「PyErr_Format」 /tmp/ccgBhADM.o: in function
__Pyx_PyObject_Call: prime_numbers_2.c:(.text+0x1483): undefined reference to「PyObject_Call」 prime_numbers_2.c:(.text+0x148d):
undefined reference to「PyThreadState_Get」
prime_numbers_2.c:(.text+0x149f): undefined reference
to「_Py_CheckRecursionLimit」 prime_numbers_2.c:(.text+0x14b6):
undefined reference to「_Py_CheckRecursiveCall」
prime_numbers_2.c:(.text+0x14eb): undefined reference
to「PyThreadState_Get」 prime_numbers_2.c:(.text+0x14fd): undefined
reference to「_Py_CheckRecursionLimit」
prime_numbers_2.c:(.text+0x150a): undefined reference
to「_Py_CheckRecursionLimit」 prime_numbers_2.c:(.text+0x1515):
undefined reference to「_Py_CheckRecursionLimit」
prime_numbers_2.c:(.text+0x1529): undefined reference
to「PyThreadState_Get」 prime_numbers_2.c:(.text+0x1542): undefined
reference to「PyErr_Occurred」 prime_numbers_2.c:(.text+0x1557):
undefined reference to「PyExc_SystemError」
prime_numbers_2.c:(.text+0x1564): undefined reference
to「PyErr_SetString」 /tmp/ccgBhADM.o: in function __Pyx_PyInt_EqObjC:
prime_numbers_2.c:(.text+0x1590): undefined reference
to「_Py_TrueStruct」 prime_numbers_2.c:(.text+0x159f): undefined
reference to「_Py_TrueStruct」 prime_numbers_2.c:(.text+0x15b2):
undefined reference to「PyLong_Type」 prime_numbers_2.c:(.text+0x169d):
undefined reference to「_Py_FalseStruct」
prime_numbers_2.c:(.text+0x16ac): undefined reference
to「_Py_FalseStruct」 prime_numbers_2.c:(.text+0x16c0): undefined
reference to「_Py_TrueStruct」 prime_numbers_2.c:(.text+0x16cf):
undefined reference to「_Py_TrueStruct」
prime_numbers_2.c:(.text+0x16d9): undefined reference
to「_Py_FalseStruct」 prime_numbers_2.c:(.text+0x16e8): undefined
reference to「_Py_FalseStruct」 prime_numbers_2.c:(.text+0x16fb):
undefined reference to「PyFloat_Type」 prime_numbers_2.c:(.text+0x1730):
undefined reference to「_Py_TrueStruct」
prime_numbers_2.c:(.text+0x173f): undefined reference
to「_Py_TrueStruct」 prime_numbers_2.c:(.text+0x1746): undefined
reference to「_Py_FalseStruct」 prime_numbers_2.c:(.text+0x1755):
undefined reference to「_Py_FalseStruct」
prime_numbers_2.c:(.text+0x176f): undefined reference
to「PyObject_RichCompare」 /tmp/ccgBhADM.o: in function
__pyx_insert_code_object: prime_numbers_2.c:(.text+0x196a): undefined reference to「PyMem_Malloc」 prime_numbers_2.c:(.text+0x1ad0): undefined
reference to「PyMem_Realloc」 /tmp/ccgBhADM.o: in function
__Pyx_CreateCodeObjectForTraceback: prime_numbers_2.c:(.text+0x1be5): undefined reference to「PyUnicode_FromString」
prime_numbers_2.c:(.text+0x1c1a): undefined reference
to「PyUnicode_FromFormat」 prime_numbers_2.c:(.text+0x1c2c): undefined
reference to「PyUnicode_FromString」 prime_numbers_2.c:(.text+0x1ca2):
undefined reference to「PyCode_New」 /tmp/ccgBhADM.o: in function
__Pyx_AddTraceback: prime_numbers_2.c:(.text+0x1e58): undefined reference to「PyThreadState_Get」 prime_numbers_2.c:(.text+0x1e6f):
undefined reference to「PyFrame_New」 prime_numbers_2.c:(.text+0x1e90):
undefined reference to「PyTraceBack_Here」 /tmp/ccgBhADM.o: in function
__Pyx_check_binary_version: prime_numbers_2.c:(.text+0x1f75): undefined reference to「PyOS_snprintf」
prime_numbers_2.c:(.text+0x1f7a): undefined reference
to「Py_GetVersion」 prime_numbers_2.c:(.text+0x1f9e): undefined
reference to「PyOS_snprintf」 prime_numbers_2.c:(.text+0x1ffa):
undefined reference to「PyOS_snprintf」
prime_numbers_2.c:(.text+0x2013): undefined reference to「PyErr_WarnEx」
/tmp/ccgBhADM.o: in function __Pyx_InitStrings:
prime_numbers_2.c:(.text+0x207f): undefined reference
to「PyUnicode_InternFromString」 prime_numbers_2.c:(.text+0x20c4):
undefined reference to「PyUnicode_Decode」
prime_numbers_2.c:(.text+0x20ef): undefined reference
to「PyUnicode_FromStringAndSize」 prime_numbers_2.c:(.text+0x211a):
undefined reference to「PyBytes_FromStringAndSize」 /tmp/ccgBhADM.o: in
function __Pyx_PyObject_IsTrue: prime_numbers_2.c:(.text+0x2168):
undefined reference to「_Py_TrueStruct」
prime_numbers_2.c:(.text+0x2179): undefined reference
to「_Py_FalseStruct」 prime_numbers_2.c:(.text+0x218c): undefined
reference to「_Py_NoneStruct」 prime_numbers_2.c:(.text+0x21a9):
undefined reference to「PyObject_IsTrue」 collect2: error: ld returned 1
exit status paultsai@paultsai-virtual-machine:~/cython/ex2$