From owner-freebsd-hackers@FreeBSD.ORG Tue Jul 5 21:55:27 2005 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 030F416A41C for ; Tue, 5 Jul 2005 21:55:27 +0000 (GMT) (envelope-from tom.schutter@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.205]) by mx1.FreeBSD.org (Postfix) with ESMTP id A4E8A43D45 for ; Tue, 5 Jul 2005 21:55:26 +0000 (GMT) (envelope-from tom.schutter@gmail.com) Received: by zproxy.gmail.com with SMTP id 8so492123nzo for ; Tue, 05 Jul 2005 14:55:26 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=RUhDK79AO3vvCAY6ms+A/RsglJAy1YJSj1nhpDiyEkAfQgwTu5mV8R/1Pgpp0bphMzBLyyjCXGIIGLFVcEpkm0fGrCjOC3wVOVTm8jo5b6XbfciR7/Cf3Au9ScSE5UfX637CXbJ8iEAPVZTKXC7Cpcj9OFbhpbKkN1wOTshVRto= Received: by 10.36.8.17 with SMTP id 17mr1679645nzh; Tue, 05 Jul 2005 14:55:26 -0700 (PDT) Received: by 10.36.25.14 with HTTP; Tue, 5 Jul 2005 14:55:26 -0700 (PDT) Message-ID: Date: Tue, 5 Jul 2005 15:55:26 -0600 From: Tom Schutter To: freebsd-hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: linking libjava.so RPATH problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Tom Schutter List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2005 21:55:27 -0000 I am having problems linking in the Java JVM libraries (libjava.so, libverify.so, libjvm.so) into my executable. With these options added to my gcc command: -L/usr/local/jdk1.4.2/jre/lib/i386 -ljava -lverify -L/usr/local/jdk1.4.2/jre/lib/i386/server -ljvm It links ok, but when I try to run it I get: $ ./testme /libexec/ld-elf.so.1: Shared object "libjava.so" not found, required by "testme" At this point ldd tells me: $ ldd testme testme: libm.so.3 =3D3D> /lib/libm.so.3 (0x2807c000) libjava.so =3D3D> not found (0x0) libverify.so =3D3D> not found (0x0) libjvm.so =3D3D> not found (0x0) libpthread.so.1 =3D3D> /usr/lib/libpthread.so.1 (0x28097000) libc.so.5 =3D3D> /lib/libc.so.5 (0x280bb000) Using -Xlinker -rpath -Xlinker PATH_TO_JRE_DIR, I can tell my executable to look in the JRE dir for libjvm.so. I have verified that RPATH has been set in the executable using objdump: $ objdump -x testme | grep RPATH RPATH /usr/local/jdk1.4.2/jre/lib/i386:/usr/local/jdk1.4.2/jre/lib/i= 386/server But when I run the executable, it cannot find libjvm.so: $ ./testme /libexec/ld-elf.so.1: Shared object "libjvm.so" not found, required by "libjava.so" At this point ldd tells me: $ ldd ./testme ./testme: libm.so.3 =3D3D> /lib/libm.so.3 (0x2807c000) libjava.so =3D3D> /usr/local/jdk1.4.2/jre/lib/i386/libjava.so (0x280= 97000) libverify.so =3D3D> /usr/local/jdk1.4.2/jre/lib/i386/libverify.so (0x280b5000) libjvm.so =3D3D> /usr/local/jdk1.4.2/jre/lib/i386/server/libjvm.so (0x280ca000) libpthread.so.1 =3D3D> /usr/lib/libpthread.so.1 (0x28702000) libc.so.5 =3D3D> /lib/libc.so.5 (0x28726000) libjvm.so =3D3D> not found (0x0) libverify.so =3D3D> not found (0x0) libjvm.so =3D3D> not found (0x0) libstdc++.so.4 =3D3D> /usr/lib/libstdc++.so.4 (0x28800000) Note that at this point on Linux, testme runs ok. If I set LD_LIBRARY_PATH, the libraries are found (no output is correct): $ LD_LIBRARY_PATH=3D3D/usr/local/jdk1.4.2/jre/lib/i386:/usr/local/jdk1.4.2/= jre/lib/i386/server ./testme $ My questions are: 1) Why is the RPATH in the executable being ignored? 2) When I add the -rpath, I get two copies of a libjvm.so reference in test= me, one that resolves correctly, and one that doesn't. Why? 3) What is the correct way of linking in libjvm.so? Thanks, --=20 Tom Schutter