For Newbies using JNI and gcc.
This little command stopped me in my tracks for
about an hour last week and I would like to share it with any one who may need it. When trying to compile a native method in C, Java and gcc here is the command:
gcc -o outfile.so hellowrold.c -shared -fpic-lcrypt -I/usr/java/jdk1.3/include-I/usr/java/jdk1.3/include/linux
where "/usr/java/jdk1.3" is the path to your jdk.
I was just hoping this would help someone.
g'day, --Ian
Thanks, but one question:
if helloworld.c needs another dynamic library...
how can I do that?
I can compile it with the header file (.h) but when I load my library (System.loadLibrary()), I reach an error:
relocation error, referenced symbol not found.
can you help me, please?
Are you using Linux?
Also after you create your shared Object file you
must move your ".so" file to a directory in your path.
Then run ldconfig and just to make sure, log out of
your account.
Is this even your problem? This is just the basic troubleshooting steps that I would take.
Post more info. if this dose not help.
Good luck,
--Ian