Python mingw32 gcc编译Cython输出:pyconfig.h的多拱位置未知(和其他警告)
我试图为Linux和Windows的python应用程序创建可执行文件,但Windows构建过程失败了 这是我的Makefile:Python mingw32 gcc编译Cython输出:pyconfig.h的多拱位置未知(和其他警告),python,c,gcc,mingw,mingw-w64,Python,C,Gcc,Mingw,Mingw W64,我试图为Linux和Windows的python应用程序创建可执行文件,但Windows构建过程失败了 这是我的Makefile: all: transpile compile-linux compile-w64 transpile: main.py cython --embed -3 -o main.c main.py compile-linux: main.c gcc -I/usr/include/python3.7 -o main main.c -lpython3.7m
all: transpile compile-linux compile-w64
transpile: main.py
cython --embed -3 -o main.c main.py
compile-linux: main.c
gcc -I/usr/include/python3.7 -o main main.c -lpython3.7m -lpthread -lm -lutil -ldl
compile-w32: main.c
i686-w64-mingw32-gcc -o main-x86.exe main.c -lpython3.7m -lpthread -lm -lutil -ldl -I/usr/include/python3.7m
compile-w64: main.c
x86_64-w64-mingw32-gcc -o main-x64.exe main.c -lpython3.7m -lpthread -lm -lutil -ldl -I/usr/include/python3.7m
(compile-w32
在all
中没有提到,因为我还没有使用它,我打算稍后再试。)
当我试图编译代码时,这是makefile/mingw32 gcc输出。linux版本编译时没有任何问题(我已经运行过一次,并且运行得很好),但windows x86_64显示了许多错误和警告:
cython --embed -3 -o main.c main.py
gcc -I/usr/include/python3.7 -o main main.c -lpython3.7m -lpthread -lm -lutil -ldl
x86_64-w64-mingw32-gcc -o main-x64.exe main.c -lpython3.7m -lpthread -lm -lutil -ldl -I/usr/include/python3.7m
In file included from /usr/include/python3.7m/Python.h:8,
from main.c:4:
/usr/include/python3.7m/pyconfig.h:104:3: error: #error unknown multiarch location for pyconfig.h
104 | # error unknown multiarch location for pyconfig.h
| ^~~~~
In file included from /usr/include/python3.7m/pyport.h:4,
from /usr/include/python3.7m/Python.h:63,
from main.c:4:
/usr/include/python3.7m/pyconfig.h:104:3: error: #error unknown multiarch location for pyconfig.h
104 | # error unknown multiarch location for pyconfig.h
| ^~~~~
In file included from /usr/include/python3.7m/pymath.h:4,
from /usr/include/python3.7m/Python.h:86,
from main.c:4:
/usr/include/python3.7m/pyconfig.h:104:3: error: #error unknown multiarch location for pyconfig.h
104 | # error unknown multiarch location for pyconfig.h
| ^~~~~
In file included from /usr/include/python3.7m/pytime.h:5,
from /usr/include/python3.7m/Python.h:87,
from main.c:4:
/usr/include/python3.7m/pyconfig.h:104:3: error: #error unknown multiarch location for pyconfig.h
104 | # error unknown multiarch location for pyconfig.h
| ^~~~~
In file included from /usr/include/python3.7m/Python.h:99,
from main.c:4:
/usr/include/python3.7m/unicodeobject.h:68:2: error: #error Must define SIZEOF_WCHAR_T
68 | #error Must define SIZEOF_WCHAR_T
| ^~~~~
In file included from /usr/include/python3.7m/pystate.h:11,
from /usr/include/python3.7m/traceback.h:8,
from /usr/include/python3.7m/Python.h:119,
from main.c:4:
/usr/include/python3.7m/pythread.h:122:5: error: #error "Require native threads. See https://bugs.python.org/issue31370"
122 | # error "Require native threads. See https://bugs.python.org/issue31370"
| ^~~~~
/usr/include/python3.7m/pythread.h:131:5: error: unknown type name ‘NATIVE_TSS_KEY_T’
131 | NATIVE_TSS_KEY_T _key;
| ^~~~~~~~~~~~~~~~
In file included from /usr/include/python3.7m/Python.h:156,
from main.c:4:
/usr/include/python3.7m/fileutils.h:95:27: warning: ‘struct stat’ declared inside parameter list will not be visible outside of this definition or declaration
95 | # define _Py_stat_struct stat
| ^~~~
/usr/include/python3.7m/fileutils.h:100:12: note: in expansion of macro ‘_Py_stat_struct’
100 | struct _Py_stat_struct *status);
| ^~~~~~~~~~~~~~~
/usr/include/python3.7m/fileutils.h:95:27: warning: ‘struct stat’ declared inside parameter list will not be visible outside of this definition or declaration
95 | # define _Py_stat_struct stat
| ^~~~
/usr/include/python3.7m/fileutils.h:104:12: note: in expansion of macro ‘_Py_stat_struct’
104 | struct _Py_stat_struct *status);
| ^~~~~~~~~~~~~~~
/usr/include/python3.7m/fileutils.h:108:12: warning: ‘struct stat’ declared inside parameter list will not be visible outside of this definition or declaration
108 | struct stat *status);
| ^~~~
make: *** [Makefile:13: compile-w64] Error 1
我已经尝试了(使用CFLAGS
)的解决方案,但没有成功
如果需要,其余的代码(包括main.py文件)是您不能将
/usr/include
和/usr/lib(64)
与MinGW一起使用。这些位置包含为Linux系统配置和编译的软件
相反,当使用MinGW for Windows交叉编译应用程序时,您需要使用并链接到为Windows构建的库来编译它
一些Linux发行版可能包含一个包
mingw64-python3-devel
(或类似版本),其中包含必要的Python头文件和库文件。如果您的发行版没有提供这种包,您需要自己使用MinGW编译PythonEDIT:显然,使用MinGW交叉编译Python本身是非常困难的。在哪里可以找到使用MinGW的Python?我在Ubuntu19.10上(对不起,忘了提了),我在apt上找不到任何相关的东西。我也在谷歌上找不到任何东西…所以。。。是否没有办法将Cython代码编译到Windows(通过Linux)?