Compiling a C generated file using Cython

50 views Asked by At

I am trying to compile a generated .c file from a .py file using

cython --embed -o hello.c hello.py

I have a hello.c generated successfully but whenever I try to compile that using gcc

gcc -Os -I <python_include_dir> -o hello hello.c -L <python_libs_dir> -lpython3 -lpthread -lm -lutil -ldl

I get lots of compilation errors

In file included from C:\Users\<user>\AppData\Local\Programs\Python\Python311\include/Python.h:38,
                 from hello.c:16:
C:\Users\<user>\AppData\Local\Programs\Python\Python311\include/pyport.h:601:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
  601 | #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
      |  ^~~~~
error: expected expression before ‘int’
15508 |                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
error: expected ‘;’ before ‘zero’
15069 |                 func_type zero = 0;\
note: in expansion of macro ‘__PYX_VERIFY_RETURN_INT_EXC’
15508 |                 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))

that's a sample of it, I get lot more.

Anyone could suggest any direction I could start digging into?

I am using gcc 11.4.0 from Cygwin, and Python 3.11.2

EDITED: Added first couple of error showing up

0

There are 0 answers