【发布时间】:2026-01-12 00:25:01
【问题描述】:
我有一个文件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 的Windows,我想将相同的文件编译为.dll。但是,当我尝试执行时
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
我是不是做错了什么?
【问题讨论】:
-
@MaR1oC 尝试在命令行中添加
-Ipath_to_sys_folder...
标签: c gcc cross-compiling cython mingw32