This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCJ .jar to .so with native method
- From: Andrew Haley <aph at redhat dot com>
- To: Joe Hoffert <jhoffert at dre dot vanderbilt dot edu>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 4 Dec 2007 13:27:54 +0000
- Subject: Re: GCJ .jar to .so with native method
- References: <1196774413.3986.18.camel@sirion.dre.vanderbilt.edu>
Joe Hoffert writes:
> I'm running into some problems converting a Java library (i.e., .jar
> file) into a native shared library (i.e., .so file) and then using that
> library with g++. In particular, I have a native method in the .jar file
> that I can't figure out how to define to the linker's satisfaction. I'm
> using GCC 4.1.2 on Linux.
>
> If I modify the gcjh-generated header file and define the native method
> inline (e.g., virtual void receive(JArray< jbyte > *, jint) {} ) the
> linker still complains about an undefined reference for the native
> method:
>
> .//libricochet.so: undefined reference to `void
> multishot::examples::RicochetApp::receive(JArray<char>*, int)'
> collect2: ld returned 1 exit status
>
> If I define the native method outside of the header file (e.g., in a C++
> source file like so:
> void multishot::examples::RicochetApp::receive(JArray< jbyte > *, jint)
> {} ) then the linker complains about a hidden symbol:
>
> /usr/bin/ld: RicochetApp: hidden symbol `void
> multishot::examples::RicochetApp::receive(JArray<char>*, int)'
> in .obj/RicochetAppMain.o is referenced by DSO
> /usr/bin/ld: final link failed: Nonrepresentable section on output
>
> Any ideas as to what I need to do to rectify my problem would be greatly
> appreciated.
This seems odd; we link C++ and Java code all the time.
Is it possible for you to reduce your problem to a small test case?
Then we can see what's going wrong. I think you're linking
incorrectly, but at the moment that's just a wild guess.
Andrew.
--
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903