JNI in Eclipse: help getting started [message #250160] |
Tue, 11 December 2007 12:06  |
Eclipse User |
|
|
|
Originally posted by: 4cs6fcg02.sneakemail.com
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig5ADC17B79CE4CF5F63657ED3
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hi,
Cross-post to cdt and jdt, since both have to do with it=E2=80=A6
I have a larger Java project in which I now want to use JNI. I hope you
believe I have good reasons for this.
I declared a native method
private native boolean evaluateWithAutomaton(BinaryTree bitTree, String
string);
in file de.uni_tuebingen.sfb.lichtenstein.binarytrees.Query
Then ran
javah -classpath . de.uni_tuebingen.sfb.lichtenstein.binarytrees.Query
in the base directory of the project (i.e. <workspace>/MSO/), which creat=
ed
de_uni_tuebingen_sfb_lichtenstein_binarytrees_Query
in that directory.
I opened the C/C++ perspective and tried to create a new C source file,
but the MSO project (which is a Java project, of course), was not
available as source folder. So I converted that project to a managed C
project.
In Project -> Properties -> C/C++ General -> Paths and Symbols, I added
the include path of my jvm to GNU C, as well as the linux subfolder (why
doesn=E2=80=99t it automatically include subfolders as well?).
I also changed the name of the configuration to Default and chose shared
library, with prefix =E2=80=98lib=E2=80=99 and ending =E2=80=98.so=E2=80=99=
=2E
This does not build. Choosing static library works though. The make
output is:
make all
Building target: libMSO.so
Invoking: GCC C Linker
gcc -shared -o"libMSO.so"
=2E/de_uni_tuebingen_sfb_lichtenstein_binarytrees_Query.o ./gtalib.o
=2E/ivb.o
/usr/lib64/gcc/x86_64-suse-linux/4.2.1/../../../../x86_64-su se-linux/bin/=
ld:
=2E/de_uni_tuebingen_sfb_lichtenstein_binarytrees_Query.o: relocation
R_X86_64_32 against `a local symbol' can not be used when making a
shared object; recompile with -fPIC
=2E/de_uni_tuebingen_sfb_lichtenstein_binarytrees_Query.o: could not read=
symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libMSO.so] Fout 1
Ok, that=E2=80=99s as far as I got. The book =E2=80=98Core Java 2=E2=80=99=
says about JNI on
Linux that I need two compilation steps:
gcc -c -fPIC -I<path/to/jdk/include> -I<path/to/jdk/include/linux>
<filename>.c
gcc -shared -o lib<filename>.so <filename>.o
I would suppose make takes care of this for me, but obviously, it doesn=E2=
=80=99t.
I would really appreciate some help here:
- how to get rid of the above problem
- Am I on the right track? Should I create a separate project for this,
or how do others do this?
Many thanks, H.
--=20
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
--------------enig5ADC17B79CE4CF5F63657ED3
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFHXsOPe+7xMGD3itQRAkGHAJ0QUW597owrSrzqF1KEozk57H7K1QCd EAYD
/UGAX5f8GQmdyPu3Vuzqd28=
=exzz
-----END PGP SIGNATURE-----
--------------enig5ADC17B79CE4CF5F63657ED3--
|
|
|
|
Powered by
FUDForum. Page generated in 0.03658 seconds