From owner-freebsd-questions@FreeBSD.ORG Fri Aug 19 19:48:56 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1B83B16A41F for ; Fri, 19 Aug 2005 19:48:56 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.93]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6CAF243D48 for ; Fri, 19 Aug 2005 19:48:54 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from flame.pc (aris.bedc.ondsl.gr [62.103.39.226]) by aiolos.otenet.gr (8.13.4/8.13.4/Debian-1) with SMTP id j7JJlpSN018435; Fri, 19 Aug 2005 22:47:51 +0300 Received: from flame.pc (flame [127.0.0.1]) by flame.pc (8.13.4/8.13.4) with ESMTP id j7JJln6H008226; Fri, 19 Aug 2005 22:47:49 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by flame.pc (8.13.4/8.13.4/Submit) id j7JJlnR5008225; Fri, 19 Aug 2005 22:47:49 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 19 Aug 2005 22:47:48 +0300 From: Giorgos Keramidas To: Jonathon McKitrick Message-ID: <20050819194748.GA7138@flame.pc> References: <20050819191335.GA76538@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050819191335.GA76538@dogma.freebsd-uk.eu.org> Cc: freebsd-questions@freebsd.org Subject: Re: Forcing symbol resolution in lib rather than bin X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2005 19:48:56 -0000 On 2005-08-19 20:13, Jonathon McKitrick wrote: > > I have a binary that links to a shared object library. That .so calls a > routine in an archive library (.a). When I link the main app with -lar-a it > works fine, even though the function is actually called in the .so. But when > I link the .so with -lar-a, the linker doesn't resolve the symbol! > > So, here's the call graph: > > bin --> shared --> archive > > If I link bin to shared and archive, it works. But if I link shared to > archive, and then bin to shared, it doesn't, even though the shared object > calls the archived function, rather than bin. > > What basic link concept am I missing here? Strange. How are you building these libraries and the program? I've uploaded a minimal test at: http://people.freebsd.org/~keramida/files/jcm-lib.tar.gz This contains three parts: libfoo/ which defines libfoo_init() and builds as a non-shared libfoo.a libbar/ which defines libbar_init() and calls libfoo_init() foobar/ a program that links with libbar.so and calls only libbar_init() Here's the output of ldd on the foobar binary and the output of running the foobar program: # flame:/tmp/jcm-lib/foobar$ LD_LIBRARY_PATH=`pwd`/../libbar ldd foobar # foobar: # libbar.so.1 => /tmp/jcm-lib/foobar/../libbar/libbar.so.1 (0x80062a000) # libc.so.6 => /lib/libc.so.6 (0x80072b000) # flame:/tmp/jcm-lib/foobar$ LD_LIBRARY_PATH=`pwd`/../libbar ./foobar # libfoo initialized at 0x80062a8a0 # libbar initialized at 0x4004e4 # flame:/tmp/jcm-lib/foobar$