Results 1 to 5 of 5

Thread: Linker fails to use static QT libraries it uses shared libraries

  1. #1
    Join Date
    Nov 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Linker fails to use static QT libraries it uses shared libraries

    I currently have two installations of QT on my linux machine. The shared version is installed in /opt/QTSDK/Desktop and the static version is installed in /usr/local/Trolltech.

    I am also using the mysql plugin.

    How do I get the linker during the build of my executable in Netbeans to use the static XX.a libraries and not the shared XX.so libraries?

    Also do I need to make any modifications to my xx/xx/xx/xx/Release/program.pro file or will that automatically be generated with " CONFIG +=static" and "QTPLUGIN += qsqlmysql " keywords once Netbeans sees I am building a static executable?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Linker fails to use static QT libraries it uses shared libraries

    Use the qmake from the Qt install that you wish to link to and the Makefile should be correctly built.

  3. #3
    Join Date
    Nov 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Linker fails to use static QT libraries it uses shared libraries

    I am using the qmake from the static version but the executable being built contains shared libraries from /usr/include. /usr/include has both X.a and X.so libraries and it appears the linker grabs the .so files first.

    How does Netbeans know it is building a static version? Is there a way to force the linker to build a static version.
    Last edited by Nuff; 4th November 2011 at 16:24.

  4. #4
    Join Date
    Nov 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Linker fails to use static QT libraries it uses shared libraries

    BTW, further review using the ldd command seems to indicate that all my QT installation files appear to be getting loaded in static form. The libraries which are suspect and which appear to be getting loaded shared are the libraries in the /usr/lib and td /lib/tls/i686/cmov directories.

    In the /usr/lib directory there is a compatible XX.a library for each xx.so library. But the xx.so libaries are getting loaded and not the xx.a libraries.

    Here are some of the libraries which are getting loaded shared instead of static from /usr/lib

    /usr/lib/libmysqlclient.so.15
    /usr/lib/libSM.so.6
    /usr/lib/libICE.so.6
    /usr/lib/libfontconfig.so.1
    /lib/tls/i686/cmov/libdl.so.2
    .
    .
    .
    /lib/libgcc_s_so.1
    Last edited by Nuff; 4th November 2011 at 19:59.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Linker fails to use static QT libraries it uses shared libraries

    Those are the dependencies against which Qt has been built. In many cases there will not be a static version of those libraries present on your system unless you go out of your way to generate one. I am not sure if it is possible, or even desirable, to try to build everything into your single executable. Certainly you would not bother with libc in most cases.

    If you are using the GNU compiler then you could experiment with the "-Bstatic" option but you will have to find a way to stop qmake inserting a "-Bdynamic" (you can probably see that in the Makefile now). I've never tried this myself. Perhaps someone else has.

Similar Threads

  1. Replies: 2
    Last Post: 10th December 2010, 08:54
  2. Qt linguist and qt shared libraries
    By webquinty in forum Qt Tools
    Replies: 0
    Last Post: 15th July 2010, 10:44
  3. qobject_cast<T> in shared libraries...
    By seim in forum Qt Programming
    Replies: 7
    Last Post: 5th January 2009, 19:23
  4. Deployment (shared libraries)
    By amagdy.ibrahim in forum Qt Programming
    Replies: 5
    Last Post: 26th June 2008, 22:55
  5. exception in shared libraries
    By big4mil in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2006, 20:51

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.