Results 1 to 6 of 6

Thread: Statically Linking... everything

  1. #1
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Statically Linking... everything

    I have question about statically linking libraries into your application under linux.
    I have a binary I am trying to distribute under linux and it is not going well.

    So my basic questions are:
    1. How do I statically link in libraries like:
    libdl.so.2 => /lib/libdl.so.2 (0x40031000)
    libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
    libm.so.6 => /lib/i686/libm.so.6 (0x40035000)
    libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40057000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

    2. I added Xinerama support along with all the others. How do I turn that off with out reconfiguring my Qt source. There has to be a way to tell it not to use them in the .pro file or something.

    3. By not having these libraries... will that make my application look / act different? I also noticed Qt said they have their own versions... should I use those if they do actually effect my application?

    I know that if I add "CONFIG += static" to my .pro file it will link Qt libraries statically... I am not worried about those. Just the others.

    Here is a list of my lib. dependencies:
    libpng12
    libSM
    libICE
    libXrender
    libXrandr
    libXcursor
    libXinerama
    libfreetype
    libfontconfig
    libXext
    libX11
    libz
    libglib-20
    libdl
    libpthread
    libstdc++
    libm
    libgcc_s
    libc
    libXfixes
    libexpat
    /lib/ld-linux.so.2

    I am getting a lot of libc.so.6 errors when I copy my app to another system.. and it doesn't work. Hopefully statically compiling it will. I also head that I should not statically link X11. If anyone has any advice... I am all ears.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

  3. #3
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Statically Linking... everything

    I have looked at those links before. I am compiling under Ubuntu.. I don't know if it supports LSB.

    There has to be another way to get it to link those guys in statically. Should I just write a Makefile from scratch? Is that easier?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Statically Linking... everything

    Basically, if you want to compile everything statically, you need a static version of each of the libraries you want linked statically. Then you need to adjust your project file, run qmake and make. Just make sure the linker can find all the static libs. Also be aware that statically linking some of the libraries (like libc) is very dangerous - the resulting binary may not be usable at all due to conflicts between two versions of libc, you'd have to link literally everything statically.

  5. #5
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Statically Linking... everything

    I have talked to a few people from Troll Tech and I think I have a good solution.

    I am going to try to compile it under linux using an older version of glibc... since I may want to support that.

    So I am going to keep everything shared... Qt libraries. I am also going to reconfigure to always use Qts version if they have one... I noticed that option but I chose to use the native libraries before.

    I guess my main question is this:

    With the setup described above... what libraries should I statically link in? Like libICE? I heard that I should not statically link in X windows libs. The problem is that I don't know if I am using the functionality of some of these libraries. How does one try to trim down their dependencies?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Statically Linking... everything

    If you are targeting LSB compliant distributions, you don't have to statically link anything that comes with LSB.

    I have looked at those links before. I am compiling under Ubuntu.. I don't know if it supports LSB.
    Try issuing a "lsb_release" command from a terminal. It should return something like this (the actual number may vary):
    LSB Version: lsb-3.1-ia32:lsb-3.1-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:cxx-3.0-ia32:cxx-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch:lsb-3.0-ia32:lsb-3.0-noarch:qt4-3.1-ia32:qt4-3.1-noarch
    If you do get this output, you have a LSB compliant distro (Ubuntu surely is LSB-compliant, but you can check anyway). Then you just need to compile your applications according to LSB rules (export LSB_MODULES=Qt4, qmake && make).

Similar Threads

  1. Replies: 3
    Last Post: 26th July 2006, 13:23
  2. Qt is compiled statically, now what ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2006, 12:46
  3. static linking issue
    By ashwini in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2006, 12:40
  4. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  5. Replies: 4
    Last Post: 20th February 2006, 09:11

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.