This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to make an application look somewhere other than /lib for

Hello all

I apologize if this is off topic for this list - I wasn't sure exactly where to ask but I thought this would be a good place to start:

I'm trying to get myself a group of libraries that I can distribute with my program so that they'll run on any distro. I run into problems all the time when different distros have different versions of system libraries like libstdc++, libgcc, libc, etc.

So, I built myself a new gcc-3.4.4 compiler and build a simple "hello world" program with it on a RH8 machine. An ldd on this program yields
[mark@locutus helloworld]$ ldd a.out => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/ (0x40015000) => /lib/i686/ (0x40102000) => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/ (0x40124000) => /lib/i686/ (0x42000000)
/lib/ => /lib/ (0x40000000)
[mark@locutus helloworld]$

Note that ldd is using the libstdc++ library that got built when the compiler was built - this seems like a good thing to me.

To make this application run on a Red Hat 7.3 machine, I grabbed the system libraries that a.out depends upon (libc, libm) and copied them into my application's directory and changed LD_LIBRARY_PATH to point there. Now ldd outputs:
[mark@locutus helloworld]$ ldd a.out => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/ (0x40015000) => ./ (0x400ee000) => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/ (0x40110000) => ./ (0x40119000)
/lib/ => /lib/ (0x40000000)
[mark@locutus helloworld]$

Note that ldd now picks up my local copies of libc and libm, but not of ld-linux. This program runs like this OK on Red Hat 7.3 when built on a RH8 machine, but not on an RHEL linux machine because the run-time linker is trying to use /lib/ with my local copy of The exact error message is:
[mark@hugh helloworld]$ ./a.out
./a.out: relocation error: ./ symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file with link time reference
[mark@hugh helloworld]$

This makes sense to me - the version of and libc must match.

So - the question is: How do I do this? Even though LD_LIBRARY_PATH points to ./ as it's first entry, ldd still looks in /lib first for I've tried the rpath option to ld at link time, but that doesn't work either. It seems that thing is somehow hardcoded to look in /lib for this library.

Is there a way to somehow configure gcc build executables that look elsewhere for, or is what I'm trying to do simply not possible? I'd really like to have a set of libraries with my program so that it's binary compatible with other distros... there must be a way. If anyone has any tips or advice I'd appreciate it.


Mark Cuss, B. Sc. Real Time Systems Analyst System Administrator CDL Systems Ltd Suite 230 3553 - 31 Street NW Calgary, AB, Canada

Phone: 403 289 1733 ext 226
Fax: 403 289 3967

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]