Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Multithreaded build with QtCreator in Windows
Recently I have faced with a problem of realization of multithreaded build in Qt Creator 2.0 in Windows. I found thread in Qt-creator mailing list which says, that the flag "-jx", specified in make params in Qt Creator, in Windows doesn't work, because "The problem seems to be that child processes don't get the parent arguments (as on Linux)."
But time - the most valuable resource and I don't want to spend it for recompilation at debugging and refactoring, I found a solution. The main idea is to run mingw32-make from .bat-file with the necessary parameters.
First of all we must set environment variable with path to mingw and specify include/lib folders (if they doesn't set by default)
Then we call mingw32-make.exe with following parameters:
-j4 — set number of jobs/threads to 4
-C % CD% — change to project dir before doing anything. "% CD%" sets automaticaly by Qt Creator
!!!remove space between % and CD. I used it because parser translate them as one symbol
-f Makefile.%1 — I used standard Debug/Release targets in QtCreator, so qmake creates two makefiles: Makefile.Debug and Makefile.Release. %1 - first argument which recieve build target name
Further in the "Build steps" section in the "Override make.exe" field in QtCreator we must specify path to our .bat-file. (e.g. C:\make.bat) and in the "make arguments" field we must specify target name.
We must set "Override make.exe" and make params in all build targets!
My .bat-file code:
Don't forget to remove space between % and CD!
Paths to mingw can differ.
C:\Qt\2010.04\mingw\bin\mingw32-make.exe -j4 -C % CD% -f Makefile.%1
The simpler approach is to use jom that we ship with creator. Just check "Use jom instead of nmake" in the Project options (in Tools->Options) and you are set. No fiddling with bat files necessary: Just pass -j 4 as additional argument to make in your project's build settings page.
[quote author="Tobias Hunger" date="1284303403"]Just pass -j 4 as additional argument to make in your project's build settings page.[/quote]
“Use jom instead of nmake” checked and after adding additional arg I have only one compiling thread.
Is there anything to build in parallel? Jom works fine for me, using up to 30 jobs in parallel to build creator.
You did add -j X as additional argument to the make step, didn't you? Does the build step configuration mention using jom? What are you trying to build? I assume your build supports more than one job at a time (otherwise your bat file would not have worked either).
I tried to build adressbook sample with -j X argument, but still only one build thread.
Build step configuration by default contains only qmake and mingw32-make, there is no jom mentions.
-j 4 added to make arguments and make line is "Make: mingw32-make.exe -j 4 -w in C:\Qt\2010.04\qt\examples\itemviews\addressbook-build-desktop"
"Use jom instead nmake" surely checked
But multithreaded build works fine via .bat
Windows XP Sp3
QtCreator 2.0.0 Built on Jun 21 2010 at 01:56:06 From revision 1c0f52a091
Hmm... jom will replace nmake. So it is only relevant form MSVC based builds. The mingw make already supports -j X fine.
So are you using MSVC builds? I just assumed you did since mingw-make should woirk without the bat-file:-)
Please check the details of the make step: Are you overriding the make command there? If you do not then jom should be used for MSVC-based projects. You still need to provide the additional -j X parameter in additional parameters (both for jom and mingw-make).
Oh, yeah.. jom override nmake and nmake it's msvc make app, I forgot it. But I used mingw based builds and -j X doesn't work for me.. I just try to build project with Qt for symbian (msvc) and it works fine with jom
Post from Qt-creator mailing list in which mentioned the same problem (Aug. 2009): "http://lists.trolltech.com/pipermail/qt-creator/2009-August/004152.html":http://lists.trolltech.com/pipermail/qt-creator/2009-August/004152.html
UPD: By the way on Ubuntu -j X argument works fine
vwidor last edited by
you can set "MAKEFILES" to "jX" in the environment (where X is the desired count of threads) to build with X threaded.
mingw32-make will also build with multiple threads by set "make" to "mingw32-make -jX".
the problem i have using jom with mingw is the fact, that jom will gather output from sterr and stout and put it on stout, which is not parsed by qt creator for errors/ warnings and therefore no issues are displayed.
same behavior using incredibuild (xgConsole) for distributed builds.
elmigranto last edited by
-j4 -f Makefile.Debug (or Release) works, but it's ugly.
Wilk last edited by
If you are using mingw, than you may define environment variable MAKE_COMMAND=mingw32-make -j<number of processes you want>. It works for me. Also it will affect any build process, that uses mingw.