Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a statically linked binary for a tool that I'm trying to run on RHLE4. The tool complains about glibc. It needs 2.4 and the one in the system is 2.3. Here is the message that it spits out:

./wkhtmltoimage-i386: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./wkhtmltoimage-i386)

Is there a way to build glibc2.4 and use it just for this tool, without replacing the glibc2.3 in the system ? While building glibc2.4 what prefix should I use for configure ?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

Since the source code for this wkhtmltoimage tool is available, I'd suggest you recompile it from source with your system's native glibc. It will likely be even quicker than recompiling glibc, which is no easy task.

A statically linked executable already includes code for all the C library calls it needs to make, so you cannot separately compile a new glibc and link the executable to it. However, programs using glibc are never completely static: some library calls (all those connected with the "Name Service", i.e., getuid() and similar) still make use of dynamically-loaded modules (the libnss*.so files usually found under /lib). This is likely why the program is failing: it is looking for some NSS module but can only find the glibc2.3 ones.

If you absolutely want to go down the road of recompiling glibc, the following could possibly work (Warning: untested!):

  1. configure glibc2.4 to install in a non-system directory, e.g. /usr/local/glibc2.4, then compile and install;

  2. run wkhtmlto* by specifying it as the first component in the dynamic linker search path (LD_LIBRARY_PATH):

    env LD_LIBRARY_PATH=/usr/local/glibc2.4/lib wkhtmltoimage ...

Update: This turned out not be so easy: having two distinct libc's on the system requires more than just recompile/install, because the libc will look for the runtime linker and dynamic-load NSS modules in fixed locations. The rtldi program allows installing different versions of the GNU libc on a single Linux system; its web page has instructions (but this is an expert-level task, so they are definitely not a step-by-step walkthrough).

Let me stress again that it will be far less work to recompile wkhtmltoimage...

share|improve this answer
    
With glibc 2.4 installed @ /usr/local/glibc2.4 , I tried env LD_LIBRARY_PATH=/usr/local/glibc2.4/lib wkhtmltoimage .... ... segmentation fault is what I get. –  letronje Oct 5 '10 at 5:32
    
Is there a way I can ask gdb to use glibc2.3 and figure out what causes the segmentation fault when glibc2.4 is applied to the binary ? LD_LIBRARY_PATH=/usr/local/glibc2.4/lib/ gdb ~/wkhtmltoimage-i386 crashes gdb. –  letronje Oct 5 '10 at 5:35
    
@letronje: the segmentation fault is caused by glibc2.4 looking for dynamically-loadable NSS modules in /lib/libnss*.so, and finding the glibc2.3 ones. I know of no solution to this... –  Riccardo Murri Oct 5 '10 at 7:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.