Date: Sun, 31 Oct 1999 20:52:54 -0500 (EST) From: "Andrew B. Sudell" <asudell@acm.org> To: dave howard <onedave@onebox.com> Cc: freebsd-java@FreeBSD.ORG Subject: Re: JNI error involving mmap Message-ID: <14364.61066.826599.262962@vega.sudell.org> In-Reply-To: <199911010045.RAA13238@mt.sri.com> References: <19991101003226.VJYK19495.mta02@onebox.com> <199911010045.RAA13238@mt.sri.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14364.61066.826599.262962>
