Cython 和交叉编译

标签 c gcc cross-compiling cython mingw32

我有一个文件 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/

相关文章:

c - 为什么我的函数不被读取?我刚刚得到 "error: called object ‘FunctionName’ 不是函数或函数指针”

gcc - gcc 链接器选项可以更改已编译二进制文件中的汇编器指令吗?

c++ - 我怎样才能让位域以正确的顺序排列我的位?

c - 关于gcc中静态库的一些问题

scala - 如何为多个 Scala 版本和差异依赖项组织代码

linux - 是否有使用 --enable-kernel=VERSION 对非常旧的内核(早于 3.2.0)进行 glibc (2.28) 编译的解决方法?

在没有参数灵活性的情况下更改链表的值

c - 采访 : function pointers vs switch case

c - Dlang LLVM 错误 : Program used external function which could not be resolved

Main 函数中的字符指针运算与其他函数中的字符指针运算