tags:

views:

1453

answers:

2

Like I said in a previous question, I'm planning on porting a Qt project from VC++ to QtCreator.

The project consists of 4 subprojects: 3 of them are libs and the last one makes the exe. The subprojects are layered, meaning that each layer has compile and link time dependencies to the layers beneath it.

The files are organized as follows:

root
  lib1
  lib2
  lib3
  main

I have created each of the subprojects in QtCreator from scratch. Each folder contains a pro file with the same name (e.g: lib1 -> lib1.pro). Using this approach I have built all the projects except the last one which must link the executable. I was getting linker errors which I fixed by manually editing the pro file and adding the code below:

LIBS +=  ../path/lib1.a \
   ../path/lib2.a \
   ../path/lib3.a

All is fine, except now lib3 complains that it can't find the symbols from lib2 and lib1. Addind LIBS to the lib2.pro file doesn't work.

I have a feeling that I'm not getting the way QtCreator works with libs and executables. How would you organize such a project so that it compiles and links correctly?

+3  A: 

After working on the problem some more, I remembered that for the GCC tool chain the order of the linker parameters is important.

Reversing the LIBS entries did the trick.

rpg
+2  A: 

Glad to see you found the answer. You may also want to add:

CONFIG += ordered

to your root directories .pro file (it is only valid in the 'SUBDIRS' profile). It forces qmake to generate Makefiles which preserve the order in which you listed them under all circumstances.

Evan Teran
Yes, I've found this option in the docs and I'm using it at the moment. The good part is that I can load my entire project at once, the bad part is that I can't build each lib individually. :-)
rpg