Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Statically linking C++ runtime libraries without comping static version of QT?
Forum Updated to NodeBB v4.3 + New Features

Statically linking C++ runtime libraries without comping static version of QT?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rsuela
    wrote on last edited by
    #1

    Hello,

    I am doing a research on how to make my Qt Applcation statically link the C++ Runtime libraries only on my Debian 6 box. I am using qt-everywhere-opensource-4.8.4.

    @MyApplication:
    linux-gate.so.1 => (0xb77d9000)
    libQtNetwork.so.4 => /usr/local/Trolltech/Qt-4.8.4/lib/libQtNetwork.so.4 (0xb7672000)
    libQtCore.so.4 => /usr/local/Trolltech/Qt-4.8.4/lib/libQtCore.so.4 (0xb7380000)
    libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7367000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7272000)
    libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb724c000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb722d000)
    libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb70e6000)
    libz.so.1 => /usr/lib/libz.so.1 (0xb70d2000)
    libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb70ce000)
    librt.so.1 => /lib/i686/cmov/librt.so.1 (0xb70c5000)
    /lib/ld-linux.so.2 (0xb77da000)@

    to

    @MyApplication:
    libQtNetwork.so.4 => /usr/local/Trolltech/Qt-4.8.4/lib/libQtNetwork.so.4 (0xb7672000)
    libQtCore.so.4 => /usr/local/Trolltech/Qt-4.8.4/lib/libQtCore.so.4 (0xb7380000)@

    i tried combining static linking of runtime while dynamically linking the qt libraries. Is this possible?

    @Sample command:
    g++ <output> -Wl,-static –Bstatic-libgcc –lstaticlib –Wl,-Bdynamic –ldynamiclib -lQtlibs@

    Is this possible without compiling static version of qt ?
    I searched the forum but i didn't found any qt documentation that prevents the user from doing static-dynamic linking.

    This is a quote from a user, but i need a point to documentation would really help. (http://qt-project.org/forums/viewthread/26973)

    [quote author="qtprojusername" date="1366592276"]"Can I statically link to libraries even if my Qt build is not static?"

    No. I don't understand it but from what I've read you have to make your Qt build static.[/quote]

    Unanswered posts:
    http://qt-project.org/forums/viewthread/29611
    http://qt-project.org/forums/viewthread/4676
    (http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows)

    Best Regards,
    Rey

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      No it is not possible to get only Qt libraries in an output of ldd.

      linux-gate.so.1 is not a file on a filesystem.
      Here is some info about "linux-gate.so.1":http://www.trilithium.com/johan/2005/08/linux-gate/
      /lib/ld-linux.so.2 is dynamic "linker/loader":http://linux.die.net/man/8/ld-linux
      You will have it because you are going to use an application with some shared libraries.

      Qt itself depends on the functions and the symbols from the other libraries and it maybe possible that loader will resolve these names into your statically linked app.
      If not then the loader will load these system libraries as a shared objects.

      You can try to compile simple app get the list of the shared objects using ldd and then substitute them with the static libraries.

      For example there is /usr/lib/gcc/i686-linux-gnu/4.6/libstdc++.a library on Ubuntu 12.04 which may be a static version of /usr/lib/i386-linux-gnu/libstdc++.so.6
      In you link command remove -lstdc++, add /usr/lib/gcc/i686-linux-gnu/4.6/libstdc++.a and see if it will eliminate libstdc++ from ldd output.

      I have not tried it by myself :-)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rsuela
        wrote on last edited by
        #3

        thank you for your response, i have tried that just now and it is still showing the
        /usr/lib/libstdc++.so.6

        There was no -lstdc++ argument in my g++ command so what i did is just add the /usr/lib/gcc/i686-linux-gnu/4.6/libstdc++.a

        Maybe it is something from QT libraries that is invoking the shared stdc++?

        Thanks,

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved