在 MinGW 中使用 -j(作业)选项构建 wxWidgets 时出错

Error building wxWidgets using -j (jobs) option with MinGW

我正在使用以下命令行为 Windows 编译 WxWidgets:

mingw32-make -f makefile.gcc BUILD=release SHARED=1 -j6

最后一个参数(-j)被运行 multiple jobs in parallel用来加速编译,在我的例子中充分利用了我的6核处理器。单线程构建通常需要 非常 的时间。

但是,我在按 Enter 时得到以下输出:

if not exist gcc_mswudll mkdir gcc_mswudll
if not exist ..\..\lib\gcc_dll mkdir ..\..\lib\gcc_dll
if not exist ..\..\lib\gcc_dll\mswu\wx\setup.h copy ..\..\include\wx\msw\setup.h ..\..\lib\gcc_dll\mswu\wx\setup.h
gcc -c -o gcc_mswudll\wxregex_regcomp.o  -O2 -mthreads  -DHAVE_W32API_H -DNDEBUG -I..\..\include -I..\..\lib\gcc_dll\msw
u -D__WXMSW__  -D_UNICODE   -MTgcc_mswudll\wxregex_regcomp.o -MFgcc_mswudll\wxregex_regcomp.o.d -MD -MP ../../src/regex/
regcomp.c
The system can not find the path specified.
        0 file(s) copied.
makefile.gcc:5651: recipe for target '..\..\lib\gcc_dll\mswu\wx\setup.h' failed
mingw32-make: *** [..\..\lib\gcc_dll\mswu\wx\setup.h] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from ..\..\include/wx/defs.h:27:0,
                 from ../../src/regex/regcustom.h:39,
                 from ../../src/regex/regguts.h:38,
                 from ../../src/regex/regcomp.c:33:
..\..\include/wx/platform.h:183:22: fatal error: wx/setup.h: No such file or directory
 #include "wx/setup.h"
                      ^
compilation terminated.
makefile.gcc:5702: recipe for target 'gcc_mswudll\wxregex_regcomp.o' failed
mingw32-make: *** [gcc_mswudll\wxregex_regcomp.o] Error 1

然后,如果我再次重复相同的命令,将显示以下输出:

if not exist ..\..\lib\gcc_dll\mswu mkdir ..\..\lib\gcc_dll\mswu
if not exist ..\..\lib\gcc_dll\mswu\wx\setup.h copy ..\..\include\wx\msw\setup.h ..\..\lib\gcc_dll\mswu\wx\setup.h
gcc -c -o gcc_mswudll\wxregex_regcomp.o  -O2 -mthreads  -DHAVE_W32API_H -DNDEBUG -I..\..\include -I..\..\lib\gcc_dll\msw
u -D__WXMSW__  -D_UNICODE   -MTgcc_mswudll\wxregex_regcomp.o -MFgcc_mswudll\wxregex_regcomp.o.d -MD -MP ../../src/regex/
regcompThe system can not find the path specified.
.c
        0 file(s) copied.
makefile.gcc:5651: recipe for target '..\..\lib\gcc_dll\mswu\wx\setup.h' failed
mingw32-make: *** [..\..\lib\gcc_dll\mswu\wx\setup.h] Error 1
mingw32-make: *** Waiting for unfinished jobs....
In file included from ..\..\include/wx/defs.h:27:0,
                 from ../../src/regex/regcustom.h:39,
                 from ../../src/regex/regguts.h:38,
                 from ../../src/regex/regcomp.c:33:
..\..\include/wx/platform.h:183:22: fatal error: wx/setup.h: No such file or directory
 #include "wx/setup.h"
                      ^
compilation terminated.
makefile.gcc:5702: recipe for target 'gcc_mswudll\wxregex_regcomp.o' failed
mingw32-make: *** [gcc_mswudll\wxregex_regcomp.o] Error 1

那么...如果我第三次尝试,编译成功。

问题:按照这个过程并行构建WxWidgets是否可以,或者是否有可能在以后使用编译的二进制文件时出现问题?

不幸的是,MSW 生成文件中确实存在一个错误,缺少各种库对 setup_h 目标的依赖性。先做 make setup_h 然后 make -jN.

应该是安全的

或者,您可以按照旧的但仍然有效的 post 中的说明使用配置进行构建,然后 make -jN 就可以正常工作。