From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 5 18:58:21 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F5A916A412 for ; Thu, 5 Oct 2006 18:58:21 +0000 (UTC) (envelope-from jeff.horner@vanderbilt.edu) Received: from mailgate02.smtp.vanderbilt.edu (mailgate02.smtp.Vanderbilt.Edu [129.59.1.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3EC2D43D46 for ; Thu, 5 Oct 2006 18:58:19 +0000 (GMT) (envelope-from jeff.horner@vanderbilt.edu) Received: from smtp10.smtp.vanderbilt.edu (smtp10.smtp.Vanderbilt.Edu [129.59.1.11]) by mailgate02.smtp.vanderbilt.edu (8.13.7/8.13.7) with ESMTP id k95IwILb017996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 5 Oct 2006 13:58:18 -0500 Received: from smtp10.smtp.vanderbilt.edu (localhost [127.0.0.1]) by smtp10.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9C+d3.7.9) with ESMTP id k95IwImp008864 for ; Thu, 5 Oct 2006 13:58:18 -0500 (CDT) Received: from [160.129.129.111] ([160.129.129.111]) by smtp10.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9.3B+d3.7.9) with ESMTP id k95IwIU7008861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 5 Oct 2006 13:58:18 -0500 (CDT) Message-ID: <452555CA.10309@vanderbilt.edu> Date: Thu, 05 Oct 2006 13:58:18 -0500 From: Jeffrey Horner User-Agent: Thunderbird 1.5.0.2 (X11/20060501) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=4.65.5446:2.3.11, 1.2.37, 4.0.164 definitions=2006-10-05_03:2006-10-05, 2006-10-03, 2006-10-05 signatures=0 X-PPS: No, score=0 Subject: Behavior of run-time linker on 6.1-RELEASE X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Oct 2006 18:58:21 -0000 Hello all, I'll apologize up front if my issue is not appropriate for this list or is answered elsewhere, but I thought I'd come straight to the source... I've noticed that setting the RPATH of a binary will help find libraries that the binary has been linked against, but the RPATH of the binary is ignored when a library itself is linked to another library. Is this expected behavior? Below is a demonstration of the behavior: hornerj@biostatbsd ~/testrtl $ cat main.c #include void print_hello_lib1(void); int main(int argc, char **argv){ printf("hello from main\n"); print_hello_lib1(); } hornerj@biostatbsd ~/testrtl $ cat lib1.c #include void print_hello_lib2(void); void print_hello_lib1(void){ printf("hello from lib1\n"); print_hello_lib2(); } hornerj@biostatbsd ~/testrtl $ cat lib2.c #include void print_hello_lib2(void){ printf("hello from lib2\n"); } hornerj@biostatbsd ~/testrtl $ make clean rm *.o *.so runmain hornerj@biostatbsd ~/testrtl $ make gcc -c main.c gcc -fPIC -c lib2.c gcc -shared -Wl,-soname,lib2.so -o lib2.so lib2.o gcc -fPIC -c lib1.c gcc -shared -Wl,-soname,lib1.so -o lib1.so lib1.o lib2.so gcc -L. -l1 -Wl,-rpath,`pwd` -o runmain main.o hornerj@biostatbsd ~/testrtl $ ./runmain /libexec/ld-elf.so.1: Shared object "lib2.so" not found, required by "lib1.so" $ gcc -v Using built-in specs. Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 3.4.4 [FreeBSD] 20050518 So, I realize I can overcome this by setting the RPATH of lib1.so, but I just wanted to make sure that this is expected (since on another platform that's not necessary). Thanks in advance, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner