PDA

View Full Version : problem with order of libs during linking



minimax
7th January 2008, 17:26
Hi.

I'm having a problem with defining the libraries for correct linking.
I have an optimized version of libz which has some additional dependencies, two libraries that must appear after -lz in command line for the linker. But no matter where I define this additional libraries, the order is never preserved after running qmake.
I found out that Qt by itself adds -lz to LIBS. But this happens after the .pro file was parsed. So, when qmake runs unify() at the end, -lz stands behind my additional libs and I get a lot of linking errors about undefined references.
So my question is, can I define library dependencies in the .pro so the order of the libraries in the command-line for the linker is in correct order? Or, is it possible to add something to variable LIBS and tell qmake that those particular parts have to stay at the end?

Thanks in advance for your help.

marcel
7th January 2008, 18:55
Depending on what platform you are using, go to QTDIR/mkspecs/*yourplatform* - win32-g++ for mingw on windows, or common/linux.conf on linux, and add your extra libs to QMAKE_LIBS.

minimax
8th January 2008, 10:32
That didn't work either, because qmake still placed the libraries somewhere in the linker command.
I've written myself a rudimentary .prl file for libz (based on the "examples" in the Qt-lib directory), which inlcudes the dependencies. That works fine now. :D