Parallel compilation of Qt in Windows

来源:互联网 发布:淘宝举报电话是多少 编辑:程序博客网 时间:2024/05/21 14:47

http://sysmagazine.com/posts/137428/


Parallel compilation of Qt-projects under Windows with usage of QtCreator — an animal mysterious and very choosy. In this small article I will tell, how all the same it to tame. Parallel compilation could be fulfill simply enough in the theory, in practice of business was not absolutely smoothly, to that in acknowledgement the infinite number of subjects at forums where various decisions was offer. Any of them, unfortunately, doing not help us. 


In the theory for a case of MinGW it are enough to specify parameter – j [number of compile processes] at a command of the assembly of make who are present to QtSDK MinGW to mingw32-make. For example, the command mingw32-make.exe – j10 turned out. 

The recommend number of compile processes made number процессоров+1. If the parameter are not set, it are considered that j=1. If to specify too great number also anything terrible does not happen. Make will launch exactly so much, how many gave an increase of productivity. 

For convenience it are possible to use a variable surrounding of %NUMBER_OF_PROCESSORS % which showed number of processors in system. The command of a type turned out 

mingw32-make.exe –j%NUMBER_OF_PROCESSORS%

However, not all so are simple. Qmake created three make-files. The common Makefile which on particular define’ам selected from Makefile.Debug and Makefile.Release depending on the assembly of release or debaga. The matter is that parameter – j not heritable. And when in QtCreator make it are caus for Makefile are caus. And here Makefile.Debug or Makefile.Release did not reach any more. 

That it to correct it is necessary to write a command in an explicit form. For example,

mingw32-make.exe –j9 –f Makefile.Debug.

Not so conveniently, but the increase of speed of the assembly strongly compensated it. For an example, the reassembly of our project on core-i7-2630 without multisequencing are carr out in 12 minutes, with a flag – j9 the assembly occupied less than two minutes. The increase of productivity six times set thinking. 

But even after instructions of such flags of the assembly by two machines it beginning to work for us, and on two are not present. At forums written that business could be in the version of Qt, in krivost of mingw, in singularities of operation of qmake, the version of OS. However, configurations of our machines was that that by process of elimination it are possible to draw an output on non-participation of versions of QtSDK, QtCreator, Windows or digit capacity of system in all to it. 

The decision appeared very simple, but during too time not such obvious. It are necessary to add абcолютный a path to mingw32-make in a variable of a surrounding of PATH. Just in case, it are more best to deliver a semicolon after a way. And after that parallel compilation wonderfully started to work, and programmers should not distract for 10 minutes each time when adding any Q_OBJECT to the project and are more its to the reassembly.

All these flags of compilation could be set in QtCreator on the tab Projects in parameters of make. 

image

I hopes, article will appear the useful and will solve questions of many at whom before the parallel assembly in QtCreator doing not work.

UPD (from comments): As to Linux/MacOS of users, to it carrying much more — enough only a key - jX. 

Also if you used the MSVC compiler problems should not be. 

In case of QtCreator it are necessary to add record
QMAKE_CXXFLAGS_RELEASE += -MP[число процессов] 
in.pro as I describing a file of the project and establishment of a variable surrounding. 

In case of the Visual Studio properties of VS of the project: «Properties» => «Configuration Properties» => «C/C ++» => «Command Line». And in the field of «Additional options» to add - MP [number of processes]. Thanks of IGHOR

Also at usage of the MSVC compiler jom could help.

The permanent part of flags can be carr out in a separate variable of a surrounding of MAKEFLAGS. Make took therefrom the install flags. For example MAKEFLAGS =-j10. And in parameters of make it are necessary only not to forget to specify a file for the assembly. For example, - f Makefile.Debug. If all of you time collected the one version it are possible to carry out all flags are whole in MAKEFLAGS and to forget about adjustment of the future projects.

Thanks all for additions.

0 0
原创粉丝点击