Hi all:
I have a problem using jni in hp-ux 10.20. We are using jdk1.1.8. (these are project requirements).
In hp-ux 10.20, g++ is not working when we use jni...it is throwing UnsatisfiedLinkError. Could anyone help me how to use jni with g++ complier and ld linker in hp-ux 10.20?
I tried the alternate way to resolve this problem as follows:
jni works fine with the aCC compiler. In our project, many programs had been compiled using g++. So, what i thought was i would use aCC complier for the program that use jni and g++ for the remaining programs (since i can not compile all these programs using aCC for some other problems).
I would write here step by step what i had done...
Step 1: javac JNIExample.java
//this program invokes the native methods written in C++
Step 2: javah -jni JNIExample
//javah creates the header file JNIExample.h
Step 3: g++ -fpic -shared -c MyCPP.cpp
//this CPP program contains certain methods which are invoked by jniCPP.cpp
//the output of this step is MyCPP.o
Step 4:
/opt/aCC/bin/aCC +z +u4 -c $JNI_INCLUDE jniCPP.cpp
//this CPP program uses jni.h and defines methods (which are in JNIExample.h). I am using aCC complier so that it does not throw UnsatisfiedLinkError in hp-ux 10.20. since g++ compiler is not working in hp-ux 10.20 when we use jni
//the output of this step is jniCPP.o
Step 5:
ld -b -o libServer.sl jniCPP.o MyCPP.o
//link using 'ld' and create a shared library libServer.sl
//this library had been loaded in JNIExample.java
Step 6:
java JNIExample
//execute the program which invokes the native method
When i do Step 6, i get the following error:
/usr/lib/dld.sl: Unresolved symbol: __nw__FUi (code) from libServer.sl
SIGABRT 6* abort (generated by abort(3) routine)
Sig = 6; code = -1.
stackbase=79D7F000, stackpointer=79D7F1C0
Abort(coredump)
What i feel is: I used ( aCC compiler & produced one object file ) and also ( used g++ compiler & produced one object file)...so it could not link these two object files...i don't know what i am thinking is correct or not?
Could anyone please give me the solution either (to use g++ complier for jni successfully in hp-ux 10.20) or ( to resolve the problem occured when using aCC and g++ compilers)
Thanks a lot in advance...
Uma