簡體   English   中英

mingw32-gcc 編譯 Cython 輸出:pyconfig.h 的未知多架構位置(和其他警告)

[英]mingw32-gcc compiling Cython output: unknown multiarch location for pyconfig.h (and other warnings)

我正在嘗試為 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 -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 編譯 Python。 編輯:顯然, 不再支持使用 MinGW 交叉編譯 Python 本身。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM