Hi All,
I have implemented a JNI library on window that call the C++ dll APIs.
Now I want my JAVA program is run on the UNIX system.
I have used WineLib to wrapper Window Dlls to the Share Object Lib (so lib)
(Using Winedump and Winegcc to build).
The functions in the so lib can work normally with my C main test function.
BUT when I call it from Java. The function can linked BUT it is crashed at the
WineLib functions:
hDLL = LoadLibraryA("HelloImpl.dll")
or
pFunc=(void*)GetProcAddress(hDLL,"?sayHello@@YAXPAD at Z");
The below is some my code:
1. Run winedump from window dll
winedump spec -f dump HelloImpl.dll -I "*.h"
2. Add Java Native Interface to HelloImpl_main.c and make a Share Object lib
(so)
winegcc HelloImpl.spec -o libhelloimpl.so HelloImpl_main.c -shared -fpic
-I/usr/java/jdk1.5.0_12/include -I/usr/java/jdk1.5.0_12/include/linux
3. From JAVA call to load so lib (I can load and link to the function)
4.Load so and call the function
It can call BUT it will have crashed at the wine lib functions.
JNIEXPORT jstring JNICALL Java_HelloImpl_sayHello
(JNIEnv *jEvn, jobject jObj){
printf("sayHello [BEGIN]\n");
char sText[255];
HELLOIMPL_global_sayHello_2(sText);
printf("sayHello [END CALL]\n");
jstring retmess;
retmess = (*jEvn)->NewStringUTF(jEvn, sText);
return retmess;
}
Crashed at: HELLOIMPL_global_sayHello_2(sText);
I also try with other way, that I have write a new so that wrapped WineLib so by
using GetProcAddress, all the function work well with a C main program, BUT it
will aslo have crashed at LoadLibrary function.
Can you help to add some comments/suggestion how to do a wrapper/ or how to
setting wine with java environment/ java app to let my java program can work
with a wrapper in so that can call the wine wrapper dll function?
Thank in advance!