0

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)
jpo38
  • 20,821
  • 10
  • 70
  • 151
  • 1
    Make is, unfortunately, not good at handling dependencies when doing a parallel build. That means it could try to build something that depends on something else that is not built yet. – Some programmer dude Jun 20 '17 at 07:53
  • @Someprogrammerdude: But QtCreator is the one invoking Make, shouldn't it support that? – jpo38 Jun 20 '17 at 08:04
  • Since QtCreator doesn't set the flag by default, then it's possible that the makefiles created by QtCreator are not set up to handle parallel builds nicely. – Some programmer dude Jun 20 '17 at 08:06
  • @Someprogrammerdude: Actually it's supported, you just need to specify the build dependencies manually, see my answer. – jpo38 Jun 20 '17 at 09:25

1 Answers1

2

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!!

jpo38
  • 20,821
  • 10
  • 70
  • 151