I have a java project in Eclipse that contains some JNI code. JNI code is cross platform - for Windows and Linux. How can I build a dll?
Thanks.
I have a java project in Eclipse that contains some JNI code. JNI code is cross platform - for Windows and Linux. How can I build a dll?
Thanks.
You have to build a .DLL for Windows and .so for Linux. You would compile C code in Linux using this syntax:
gcc -shared yourcode.c -I/usr/lib/gcc/x86_64-redhat-linux/3.4.3/include/ -o yourLib.so
import in java using
static {
System.out.println(System.getProperty("java.library.path"));
System.loadLibrary("yourlib");
}
For Windows How to compile C to DLL
I assume you have some C/C++
code. To create a dll
(windows) you have to compile your code (you could use Visual C++ Express for example, or mingw: gcc). In linux just use gcc
to build the library.
Once you built the library for you platform add it to the library path with -Djava.library.path=<folder containing the library>
.
hth