Re: GCJ .jar to .so with native method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux