Important: Please read the Qt Code of Conduct -

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

  • 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: => (0xb77d9000) => /usr/local/Trolltech/Qt-4.8.4/lib/ (0xb7672000) => /usr/local/Trolltech/Qt-4.8.4/lib/ (0xb7380000) => /lib/i686/cmov/ (0xb7367000) => /usr/lib/ (0xb7272000) => /lib/i686/cmov/ (0xb724c000) => /lib/ (0xb722d000) => /lib/i686/cmov/ (0xb70e6000) => /usr/lib/ (0xb70d2000) => /lib/i686/cmov/ (0xb70ce000) => /lib/i686/cmov/ (0xb70c5000)
    /lib/ (0xb77da000)@


    @MyApplication: => /usr/local/Trolltech/Qt-4.8.4/lib/ (0xb7672000) => /usr/local/Trolltech/Qt-4.8.4/lib/ (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. (

    [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:

    Best Regards,

  • No it is not possible to get only Qt libraries in an output of ldd. is not a file on a filesystem.
    Here is some info about "":
    /lib/ is dynamic "linker/loader":
    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/
    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 :-)

  • thank you for your response, i have tried that just now and it is still showing the

    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++?


Log in to reply