python script converted to C code via Cython is throwing this error upon execution: undefined symbol: PyObject_SelfIter

Viewed 22

I converted a Python script to C code via Cython, creating "test.c". I then compile with:

 gcc -static test.c -I/home/me/Python-3.9.12/include/python3.9 -o test.exe  -L/home/me/Python-3.9.12/lib -lpython3.9 -lpthread -lutil -lrt -lm -ldl

When I run "test.exe" I get this error:

 Original error was: /home/me/NEWER/numpy/core/_multiarray_umath.cpython-39-x86_64-linux-gnu.so: undefined symbol: PyObject_SelfIter

What I don't understand is that the symbol PyObject_SelfIter is defined in libpython3.9.a which I link in as seen in the compilation line. Why doesn't this linking take care of the undefined symbol noted above? How can I get around this error?

2 notes:

  1. I am linking statically because I want to run the resulting executable on an Android system
  2. as a test, I tried compiling without the -static flag, and the executable still yields the same error

thanks for any tips.

0 Answers
Related