views:

336

answers:

3

Good morning,

on a 64bit RedHat box we have to compile and run a 32bit application. Meanwhile I managed to compile the gcc version needed (4.0.3) and all required runtime libraries in 32bit and have set the LD_LIBRARY_PATH to point to the 32bit versions, but now during the remaining build process, a small java program needs to be executed which is installed in /usr/bin as a 64bit program, which now finds the 32bit version of libgcc_s.so first.

In general, if I set the LD_LIBRARY_PATH to the 32bit versions, I break the 64bit programs and vice versa.

How it this supposed to work at all? I am certain I am not the first person with this problem at hand. How is it solved usually?

Regards, Stefan

+1  A: 

As a workaround, wrap the Java call in a small shell script which unsets LD_LIBRARY_PATH and then calls the executable. Alternatively, this might also work:

LD_LIBRARY_PATH= java...

Note the space between "=" and the name of the executable.

Aaron Digulla
Thanks for the idea, it will probably work in this particular case. I was however looking for a more generalized approach, which doesn't require to change the build scripts on the machine.
struppi
Yes; I'm not sure how the automatic pickup works. I suggest to install a 32bit app and run "ldd" on it. If that picks of the libraries, then it must be some magic happening in /etc/ld.conf and ldconfig: http://linux.die.net/man/8/ldconfig
Aaron Digulla
+1  A: 

On Solaris one can use LD_LIBRARY32_PATH and LD_LIBRARY64_PATH, but that isn't supported on Linux.

In general, you should just never need to set LD_LIBRARY_PATH at all in the first place:

  • either install needed libraries into /usr/lib32 or /usr/lib64 as appropriate, or
  • build your 32-bit application with -Wl,-rpath=/path/to/32-bit/libs
Employed Russian
A: 

Just set LD_LIBRARY_PATH to both paths (use colons to delimit). The linker will ignore the libraries that it cannot read.

Adam Goode
That would be nice, but - at least in my environment - it did not appear to work. The loader did complain; it did not simply skip the libraries that do not match the bit-ness. Sadly!
struppi
This is very strange, could you describe how things failed? Also, perhaps post the output of `ldd`?
Adam Goode