Results 1 to 3 of 3

Thread: problem with order of libs during linking

  1. #1
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy problem with order of libs during linking

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with order of libs during linking

    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.

  3. #3
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: problem with order of libs during linking

    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.

Similar Threads

  1. Linking problem on Mac os x 10.4
    By maverick_pol in forum General Programming
    Replies: 0
    Last Post: 6th January 2008, 14:09
  2. why linking problem with QGLWidget???
    By Shuchi Agrawal in forum Newbie
    Replies: 17
    Last Post: 16th March 2007, 10:45
  3. QDataTable problem in the order
    By cristiano in forum Qt Programming
    Replies: 3
    Last Post: 22nd January 2007, 22:58
  4. Runtime dynamic linking + Qt4 problem
    By _Ramirez_ in forum Qt Programming
    Replies: 5
    Last Post: 11th February 2006, 14:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.