views:

383

answers:

2

I have built a static version of qt and download a static version of glibc. Now I would like to link glibc statically to my qt application. I know about going into the .pro and adding the line LIBS += -L path/to/static_lib but I am wondering if these that is enough? Will it still link glibc statically even though the OS I am building on has the dynamic libraries also? The reason I am doing this is to deploy the application in a standalone manner. (After installing and updating Red Hat 5.3 glibc_2.9 was not found on the target computer)

+2  A: 

Passing -static to gcc will force it to link statically when possible.

Alternatively, download and install CentOS 5 and build on that.

Ignacio Vazquez-Abrams
so building on Cent OS will make the binary compatible with more distros?
yan bellavance
CentOS is binary-compatible with RHEL.
Ignacio Vazquez-Abrams
Thanks I didnt know about this. I guess even better would be to build straight from RHEL, I have one running in the office. Also, I heard that statically linking libc is not a trivial task, this implies statically linking everything and there are some runtime implications. After statically linking libc I got some warnings from make and when I ran it on RHEL I got a segmentation fault
yan bellavance
quote from http://www.trilithium.com/johan/2005/06/static-libstdc/ says: "The problem is not so much linking libstdc++ statically – it is just a library, after all – but the runtime support required by C++ code in general, to enable features like RTTI and exception handling."
yan bellavance
ps: gonna up vote you as soon as my voting cooldown wears off :P
yan bellavance
+1  A: 

As you discovered, linking fully statically with glibc is not possible, because for instance nss support is loaded dynamically. However, the required glibc version depends mostly on the features you actually use.

Anyway, I think you should instead use Linux Standard Base, also because of reasons exposed here.

Blaisorblade