在Windows 7上使用Qt 5.1和jom进行多核编译失败

时间:2013-09-08 06:29:33

标签: windows qt5

我已经通过Qt Online安装程序安装了Qt 5.1.1和MinGW 4.8以及QtCreator。 我启动了Qt创建器并使用基于QMainWindow的MainWindow类创建了新项目(Qt应用程序桌面)(默认)。它工作正常,并在编译后弹出主窗口。

然而,当我使用C:\ Qt \ Qt5.1.1 \ Tools \ QtCreator \ bin \ jom.exe而不是C:\ Qt \ Qt5.1.1 \ Tools \ mingw48_32 \ bin \ mingw32-make.exe时,我获得了如下的输出。

jom 1.0.13 - empower your cores

C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe -f Makefile.Release
g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../foobar -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtWidgets' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtGui' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtCore' -I'release' -I'.' -I'.' -I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/mkspecs/win32-g++' -o release/main.o ../foobar/main.cpp
In file included from ../foobar/main.cpp:1:0:
../foobar/mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
 #include <QMainWindow>
                       ^
compilation terminated.
jom: D:\work\build-foobar-Desktop_Qt_5_1_1_MinGW_32bit-Release\Makefile.Release [release\main.o] Error 1
jom: D:\work\build-foobar-Desktop_Qt_5_1_1_MinGW_32bit-Release\Makefile [release] Error 2
15:17:38: Process "C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe" stopped with code 2
Error while building/deploying project foobar (kit: Desktop Qt 5.1.1 MinGW 32bit)
During step 'Make'
15:17:38: Elapsed time: 00:00.

我的.pro是这样的。

#-------------------------------------------------
#
# Project created by QtCreator 2013-09-08T15:16:13
#
#-------------------------------------------------
QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = foobar
TEMPLATE = app
SOURCES += main.cpp\ mainwindow.cpp
HEADERS  += mainwindow.h
FORMS    += mainwindow.ui

我认为.pro greaterThan(QT_MAJOR_VERSION, 4): QT += widgets和编译-I'C:/Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtWidgets'期间输出中的行看起来不错,但失败了。

如何在Windows 7(32位)上使用Qt 5.1和jom进行编译?

提前致谢。

2 个答案:

答案 0 :(得分:1)

Jom取代了nmake,而不是MinGW的make

nmake是用于编译makefile的 Visual Studio 命令行工具。不幸的是,该工具只使用一个核心(并行构建在Visual Studio中直接或使用MSBuild处理,我不太确定)。话虽如此,JörgBornemannwrote a tool called jom-j命令添加到nmake中。它允许您跨不同的线程使用Visual C ++编译器编译代码

另一端的MinGW包含(其中包括)Windows的 GNU GCC编译器的端口。作为一个端口,MinGW不是所有可能与GCC有关的东西,我想-jN就是其中之一。但是,MinGW确实支持将尽可能多地生成进程的选项-j(请注意,如果使用此选项,则在编译时可能无法使用计算机)。

在您的情况下,您可能希望使用MinGW,因为您的Qt版本是使用它编译的。如果要使用Visual Studio,则必须安装它,但也可以:

  • 重新编译Qt(以及所有其他库依赖项)或
  • 下载与您刚刚安装的Visual Studio版本对应的二进制文件。

完成此操作后,使用jom只需使用QtCreator即可。

答案 1 :(得分:0)

在我的情况下,我通过在项目设置中覆盖系统环境PATH来修复此错误,方法是只添加到qt,mingw和qtcreator的bin路径:“E:\ Qt \ 4.8.1 \ bin; E:\ qt \ mingw-4.4 .0 \ bin; E:\ Qt \ qtcreator-4.0.0 \ bin“并在运行qmake和Rebuild之后