Undefined Reference Py_XX, python 3.10.12, cython 3.0.0

187 views
Skip to first unread message

x y

unread,
Aug 13, 2023, 1:25:32 AM8/13/23
to cython-users
Hey,

I am doing a small test with Ubuntu 22.04, Python 3.10.12, Cython 3.0.0.
I would like to compile and get an executable of a small 2 lines python program as a test.
test.py
  • import os
  • os.system('ls -al')
I am compiling with
  • cython -3 --fast-fail  test.py --embed
  • gcc  `python3-config --cflags --ldflags` -I/usr/lib/x86_64-linux-gnu/ -L/usr/lib/x86_64-linux-gnu/ -lpython3.10  -v test.c -o test

And when compiling to get an exe with GCC i got 1000 of errors like undefined reference to Py_x structure.
Not sure what is wrong as i have tried to insert the relevant python3.10 libraries in the GCC  command line.

Example of errors:
/home/test/test_cython/test.c:2122: undefined reference to `PyModuleDef_Init'
/usr/bin/ld: /tmp/ccniLBDE.o: in function `__Pyx_PyObject_GetAttrStr':
/home/test/test_cython/test.c:2554: undefined reference to `PyObject_GetAttr'
/usr/bin/ld: /tmp/ccniLBDE.o: in function `__Pyx_PyErr_GivenExceptionMatches':
/home/test/test_cython/test.c:4298: undefined reference to `PyErr_GivenExceptionMatches'
/usr/bin/ld: /tmp/ccniLBDE.o: in function `__Pyx_PyObject_Call':
/home/test/test_cython/test.c:2796: undefined reference to `PyObject_Call'
/usr/bin/ld: /tmp/ccniLBDE.o: in function `__Pyx_PyObject_GetAttrStrNoError':
/home/test/test_cython/test.c:2570: undefined reference to `_PyObject_GenericGetAttrWithDict'
/usr/bin/ld: /tmp/ccniLBDE.o: in function `main':
/home/test/test_cython/test.c:3552: undefined reference to `Py_DecodeLocale'
/usr/bin/ld: /home/test/test_cython/test.c:3564: undefined reference to `PyMem_RawFree'
/usr/bin/ld: /tmp/ccniLBDE.o: in function `__Pyx_main':
/home/test/test_cython/test.c:3372: undefined reference to `PyImport_AppendInittab'
/usr/bin/ld: /home/test/test_cython/test.c:3372: undefined reference to `PyImport_AppendInittab'
/usr/bin/ld: /home/test/test_cython/test.c:3372: undefined reference to `PyImport_AppendInittab'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status


Reply all
Reply to author
Forward
0 new messages