在 aarch64 上编译 Cython 时出现链接错误

时间:2021-07-08 11:01:15

标签: c cython arm64 cythonize

我正在尝试使用 cython 在 aarch64 上制作可执行文件。

我知道这些标志过多,我尝试在我的 x86_64 系统上编译它并且它只与 gcc -I/usr/include/python3.9 -lpython3.9 sample.c 一起工作,但在 aarch64 上它会出现这些长链接错误。

如果有人设法使用 cython 在 arm64 上制作可执行文件,那也会有所帮助。

root@f6753f1e6043:~# cython sample.pyx --embed -X language_level=3
root@f6753f1e6043:~# python3-config --ldflags --libs --cflags --embed
-L/usr/lib/python3.8/config-3.8-aarch64-linux-gnu -L/usr/lib -lpython3.8 -lcrypt -lpthread -ldl  -lutil -lm -lm 
-lpython3.8 -lcrypt -lpthread -ldl  -lutil -lm -lm 
-I/usr/include/python3.8 -I/usr/include/python3.8  -Wno-unused-result -Wsign-compare -g -fdebug-prefix-map=/build/python3.8-pqDzXG/python3.8-3.8.10=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector -Wformat -Werror=format-security  -DNDEBUG -g -fwrapv -O3 -Wall

root@f6753f1e6043:~# gcc $(python3-config --ldflags --libs --cflags --embed) sample.c
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `__Pyx_PyObject_GetAttrStr':
/root/sample.c:1489: undefined reference to `PyObject_GetAttr'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `__Pyx_copy_spec_to_module':
/root/sample.c:1258: undefined reference to `PyObject_GetAttrString'
/usr/bin/ld: /root/sample.c:1261: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /tmp/ccBjCsrj.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_Py_NoneStruct' which may bind externally can not be used when making a shared object; recompile with -fPIC
/root/sample.c:1261:(.text.unlikely+0xbc): dangerous relocation: unsupported relocation
/usr/bin/ld: /root/sample.c:1261: undefined reference to `_Py_NoneStruct'
/usr/bin/ld: /root/sample.c:1262: undefined reference to `PyDict_SetItemString'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `_Py_DECREF':
/usr/include/python3.8/object.h:478: undefined reference to `_Py_Dealloc'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `__Pyx_copy_spec_to_module':
/root/sample.c:1265: undefined reference to `PyExc_AttributeError'
/usr/bin/ld: /tmp/ccBjCsrj.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `PyExc_AttributeError' which may bind externally can not be used when making a shared object; recompile with -fPIC
/root/sample.c:1265:(.text.unlikely+0xfc): dangerous relocation: unsupported relocation
/usr/bin/ld: /root/sample.c:1265: undefined reference to `PyExc_AttributeError'
/usr/bin/ld: /root/sample.c:1265: undefined reference to `PyErr_ExceptionMatches'
/usr/bin/ld: /root/sample.c:1266: undefined reference to `PyErr_Clear'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `__Pyx_check_single_interpreter':
/root/sample.c:1237: undefined reference to `PyThreadState_Get'
/usr/bin/ld: /root/sample.c:1237: undefined reference to `PyInterpreterState_GetID'
/usr/bin/ld: /root/sample.c:1250: undefined reference to `PyExc_ImportError'
/usr/bin/ld: /tmp/ccBjCsrj.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `PyExc_ImportError' which may bind externally can not be used when making a shared object; recompile with -fPIC
/root/sample.c:1250:(.text.unlikely+0x17c): dangerous relocation: unsupported relocation
/usr/bin/ld: /root/sample.c:1250: undefined reference to `PyExc_ImportError'
/usr/bin/ld: /root/sample.c:1250: undefined reference to `PyErr_SetString'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `__pyx_pymod_create':
/root/sample.c:1278: undefined reference to `PyObject_GetAttrString'
/usr/bin/ld: /root/sample.c:1280: undefined reference to `PyModule_NewObject'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `_Py_DECREF':
/usr/include/python3.8/object.h:478: undefined reference to `_Py_Dealloc'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `__pyx_pymod_create':
/root/sample.c:1283: undefined reference to `PyModule_GetDict'
/usr/bin/ld: /tmp/ccBjCsrj.o: in function `_Py_DECREF':
/usr/include/python3.8/object.h:478: undefined reference to `_Py_Dealloc'
/usr/bin/ld: /tmp/ccBjCsrj.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `__stack_chk_guard@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /tmp/ccBjCsrj.o(.text.unlikely+0x2e0): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17'
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

0 个答案:

没有答案
相关问题