我有一个文件 test.pyx
和一个由 $ cython test.pyx
生成的 test.c
。我想用 gcc 创建一个共享对象 test.so
以便我可以将它导入 Python。为 linux x86-64 编译
gcc -Wall -fPIC -I /usr/include/python2.7 -shared -o test.so test.c
成功终止。
我想使用 mingw32
将同一个文件编译为 .dll
for windows。但是,当我尝试执行
i586-mingw32msvc-gcc -Wall -fPIC -I /usr/include/python2.7 -shared -o test.dll test.c
我收到这个错误:
test.c:1: warning: -fPIC ignored for target (all code is position independent)
In file included from /usr/include/python2.7/Python.h:58,
from test.c:16:
/usr/include/python2.7/pyport.h:338:24: error: sys/select.h: No such file or directory
我做错了什么吗?
最佳答案
你用它来做:
<your_compiler> <cython_generated_c_file> -o <your_outputfilename> -fPIE -lpython<python_version>
<cflags> <ldflags>
获取cflags:
python-config --cflags
对于 ldflags:
python-config --ldflags
关于Cython 和交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25012787/