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:
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 -
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 :-)
-
thank you for your response, i have tried that just now and it is still showing the
/usr/lib/libstdc++.so.6There 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,