From owner-freebsd-java Sun Oct 31 17:53:17 1999 Delivered-To: freebsd-java@freebsd.org Received: from renoir.op.net (renoir.op.net [209.152.193.4]) by hub.freebsd.org (Postfix) with ESMTP id 6AA5E15012 for ; Sun, 31 Oct 1999 17:53:05 -0800 (PST) (envelope-from asudell@mail.Op.Net) Received: from vega.sudell.org (d-bm6-05.ppp.op.net [209.152.206.5]) by renoir.op.net (o1/$Revision: 1.18 $) with ESMTP id UAA00598; Sun, 31 Oct 1999 20:53:02 -0500 (EST) Received: (from asudell@localhost) by vega.sudell.org (8.9.2/8.9.2) id UAA00438; Sun, 31 Oct 1999 20:52:57 -0500 (EST) (envelope-from asudell@mail.Op.Net) From: "Andrew B. Sudell" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sun, 31 Oct 1999 20:52:54 -0500 (EST) To: dave howard Cc: freebsd-java@FreeBSD.ORG Subject: Re: JNI error involving mmap In-Reply-To: <199911010045.RAA13238@mt.sri.com> References: <19991101003226.VJYK19495.mta02@onebox.com> <199911010045.RAA13238@mt.sri.com> X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <14364.61066.826599.262962@vega.sudell.org> Reply-To: asudell@acm.org Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Nate Williams writes: > > thanks for the tip. i had not been compiling with the PIC option as > > you suggest, however doing it that way seems to have no effect on the > > error i'm getting. any other ideas? > > You also need to give the linker a bunch of flags to build a correctly > functioning shlib, but as I said before, someone else may know the magic > incantation. > > I'm 99% positive you shared library is in-correct, and -pic as well as a > number of other options must be used to get a correctly function shlib. > I haven't had to do this in a long time (FreeBSD 2.2.7, JDK 1.0.X, old pre-JNI native interface, a.out), but I'll try to cover the differences, unless someone with more recent experience jumps in. Nate's story sounds about right, though there's not a whole lot of stuff you need to build a shlib. First build all objects with position independent code (-fpic in most cases or -fPIC if needed for "large displacement branches). I'd go with -fpic, and if things don't get better, try -fPIC, which can't hurt, only slow down function calls. Next link the objects into a shared object. When I last did this the the linker options was -Bshareable. A quick look at ld, shows that is likely to still work but the man page is pushing -shared as the preferred way. One thing you might try, as a way of checking your library outside of java is to manually load it with dlopen(), and call a function or two after resolving them with dlsym(). That's essentially what JNI is doing under the covers. Drew -- Drew Sudell asudell@op.net http://www.op.net/~asudell To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message