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@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!
WineLib and Java Native Interface (JNI) - UNIX
Re: WineLib and Java Native Interface (JNI) - UNIX
You can't run winelib by itself. It can only work under Wine.huutri wrote: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:
Re: WineLib and Java Native Interface (JNI) - UNIX
"You can't run winelib by itself. It can only work under Wine."
YES, so how to config to let JNI/ UNIX JAVA environment understand Wine?
Anyway to let my JAVA can work with wrapper?
The steps are i have implemented are:
on WINDOWS
1. C++ window Dll -> JNI Wrapper DLL->JAVA (Worked well)
on Lunix
1. C++ window Dll -> Winedump with dll-> get new .c and .h and spec file.
2. Include JNI wrapper .h and add new JNI function to .c
winedump spec -f dump HelloImpl.dll -I "*.h"
3. Using winegcc to make share object lib
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
4. Load so share object lin in JAVA. It can load and call the function
BUT it will crashed when calling winelib functions.
It seems it doesn't understand winelib in JVM at runtime.
Can anybody can help to add some suggestion how to solve this problem?
YES, so how to config to let JNI/ UNIX JAVA environment understand Wine?
Anyway to let my JAVA can work with wrapper?
The steps are i have implemented are:
on WINDOWS
1. C++ window Dll -> JNI Wrapper DLL->JAVA (Worked well)
on Lunix
1. C++ window Dll -> Winedump with dll-> get new .c and .h and spec file.
2. Include JNI wrapper .h and add new JNI function to .c
winedump spec -f dump HelloImpl.dll -I "*.h"
3. Using winegcc to make share object lib
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
4. Load so share object lin in JAVA. It can load and call the function
BUT it will crashed when calling winelib functions.
It seems it doesn't understand winelib in JVM at runtime.
Can anybody can help to add some suggestion how to solve this problem?
-
- Level 5
- Posts: 336
- Joined: Mon Nov 24, 2008 8:10 am
As vitamin set Winelib is not a magical library against which native libraries can link. Wine needs a lot of magic before it can run (registry, filesystem, kernel) which is for a part done by e.g. wineserver.
A simple way would be to install a win32 jvm and run the app from there. A second way would be to write a winelib bridge app which communicates with your real app using e.g. unix sockets (from within winelib code you can make native linux calls).
A simple way would be to install a win32 jvm and run the app from there. A second way would be to write a winelib bridge app which communicates with your real app using e.g. unix sockets (from within winelib code you can make native linux calls).
Re: WineLib and Java Native Interface (JNI) - UNIX
Install windows java version on Wine. And run it from there.huutri wrote:"You can't run winelib by itself. It can only work under Wine."
YES, so how to config to let JNI/ UNIX JAVA environment understand Wine?