简体   繁体   中英

Is mingw32-make `-j` option broken?

I'm compiling a big project (~40 libraries and 1 executable) using QtCreator /w Qt 5.6 for Android. QtCreator uses "mingw492_32\\bin\\mingw32-make.exe" to operate the build.

When I compile with default options, all my project compiles fine.

When I add -j4 or -j8 to mingw32-make.exe command within QtCreator project settings, the build is faster but randomly fails. At some point, while library B links with A , I can see in the log that it tries to link B while A compilation is not completed yet, so it reports cannot open ..../libA.so .

Note that:

  • the fact that B links with A is managed by LIBS += -l$$OUT_PWD/../../lib/A/libA.so in B 's .pro file
  • B appears after A in top level .pro file ( SUBDIRS += A.pro B.pro )

According to Qmake project dependencies (linked libraries) , dependecies has to be specified explictely in the .pro files.

So I added in my top level .pro file (after SUBDIRS += A.pro B.pro ):

CONFIG += ordered
B.depends += A

Ans also PRE_TARGETDEPS += $$OUT_PWD/../../lib/A/libA.so in B.so

With those changes, the build with -j4 option apparently works, and it divided my project compilation time by 3!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM