From owner-freebsd-java@FreeBSD.ORG Thu Jun 30 20:58:30 2005 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 016D316A41C for ; Thu, 30 Jun 2005 20:58:30 +0000 (GMT) (envelope-from tom.schutter@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) by mx1.FreeBSD.org (Postfix) with ESMTP id AF32A43D1D for ; Thu, 30 Jun 2005 20:58:29 +0000 (GMT) (envelope-from tom.schutter@gmail.com) Received: by zproxy.gmail.com with SMTP id 8so102589nzo for ; Thu, 30 Jun 2005 13:58:29 -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=ru1oYoBMHUxchjVf8/TQIL11hYaEwgKFG15krIBz63Amqz/zJmoPp+TVg1OB8ZhVD3W0nDzxzsJbrAT99J8kjyQMIqCY5o6Em9kX8Gd0NEXLL4qV4cDrquzSnTgr0oyIl15V9G8F1pbaTdS67WZDixOiTvrwaV6/P3DT0k28cQ4= Received: by 10.36.66.13 with SMTP id o13mr537908nza; Thu, 30 Jun 2005 13:52:09 -0700 (PDT) Received: by 10.36.25.14 with HTTP; Thu, 30 Jun 2005 13:52:09 -0700 (PDT) Message-ID: Date: Thu, 30 Jun 2005 14:52:09 -0600 From: Tom Schutter To: freebsd-java@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: libjava.so RPATH problem X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Tom Schutter List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2005 20:58:30 -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 =3D> /lib/libm.so.3 (0x2807c000) libjava.so =3D> not found (0x0) libverify.so =3D> not found (0x0) libjvm.so =3D> not found (0x0) libpthread.so.1 =3D> /usr/lib/libpthread.so.1 (0x28097000) libc.so.5 =3D> /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/= i386/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 =3D> /lib/libm.so.3 (0x2807c000) libjava.so =3D> /usr/local/jdk1.4.2/jre/lib/i386/libjava.so (0x2809= 7000) libverify.so =3D> /usr/local/jdk1.4.2/jre/lib/i386/libverify.so (0x280b5000) libjvm.so =3D> /usr/local/jdk1.4.2/jre/lib/i386/server/libjvm.so (0x280ca000) libpthread.so.1 =3D> /usr/lib/libpthread.so.1 (0x28702000) libc.so.5 =3D> /lib/libc.so.5 (0x28726000) libjvm.so =3D> not found (0x0) libverify.so =3D> not found (0x0) libjvm.so =3D> not found (0x0) libstdc++.so.4 =3D> /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=3D/usr/local/jdk1.4.2/jre/lib/i386:/usr/local/jdk1.4.2/jr= e/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? --=20 Tom Schutter