From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3460 invoked by alias); 14 Jul 2005 21:52:08 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 3369 invoked by uid 22791); 14 Jul 2005 21:52:04 -0000 Received: from [207.34.103.174] (HELO cdlsystems.com) (207.34.103.174) by sourceware.org (qpsmtpd/0.30-dev) with SMTP; Thu, 14 Jul 2005 21:52:04 +0000 Received: from pinchy by cdlsystems.com (Cipher TLSv1:RC4-MD5:128) (MDaemon.PRO.v7.2.0.R) with ESMTP id md50000242985.msg for ; Thu, 14 Jul 2005 15:51:59 -0600 Message-ID: <00b401c588be$477aa170$ab0e10ac@pinchy> Reply-To: "Mark Cuss" From: "Mark Cuss" To: Subject: How to make an application look somewhere other than /lib for ld-linux.so.2 Date: Thu, 14 Jul 2005 21:52:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Authenticated-Sender: mark@cdlsystems.com X-Spam-Processed: cdlsystems.com, Thu, 14 Jul 2005 15:51:59 -0600 (not processed: message from valid local sender) X-Return-Path: mcuss@cdlsystems.com X-MDaemon-Deliver-To: gcc@gcc.gnu.org X-MDAV-Processed: cdlsystems.com, Thu, 14 Jul 2005 15:52:03 -0600 X-SW-Source: 2005-07/txt/msg00616.txt.bz2 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 libstdc++.so.6 => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/libstdc++.so.6 (0x40015000) libm.so.6 => /lib/i686/libm.so.6 (0x40102000) libgcc_s.so.1 => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/libgcc_s.so.1 (0x40124000) libc.so.6 => /lib/i686/libc.so.6 (0x42000000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (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 libstdc++.so.6 => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/libstdc++.so.6 (0x40015000) libm.so.6 => ./libm.so.6 (0x400ee000) libgcc_s.so.1 => /cdl/apps/.software/linux/gcc-3.4.4-x86-x86/lib/libgcc_s.so.1 (0x40110000) libc.so.6 => ./libc.so.6 (0x40119000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (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/ld-linux.so.2 with my local copy of libc.so.6. The exact error message is: [mark@hugh helloworld]$ ./a.out ./a.out: relocation error: ./libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux.so.2 with link time reference [mark@hugh helloworld]$ This makes sense to me - the version of ld-linux.so 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 ld-linux.so.2. 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 ld-linux.so.2, 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. Thanks Mark 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 www.cdlsystems.com