如何创建jni DLL文件?How can a JNI DLL be created?
JNI is the Java Native Interface, you will need to download and install the Java SDK. Note the installation directory (ie/ c:\j2sdk1.4.1_02 ) for use later. If you are using MSYS add a line similiar to the following in /etc/fstab and then restart MSYS:
c:/j2sdk1.4.1_02 /java
In MSYS the JNI DLL can be generated using the following (NOTE: -Wl has an 'L' not a '1'):
gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at \
-I/java/include -I/java/include/win32 \
-shared -o JavaImp.dll someJavaImp.c
In a standard command console it can be generated as follows (one continuous line):
gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at
-Ic:/j2sdk1.4.1_02/include -Ic:/j2sdk1.4.1_02/include/win32
-shared someJavaImp.c -o JavaImp.dll
要使用上述的JavaImp.dll库文件 ,参考如下Java类代码添加到.java文件里:
System.loadLibrary( "JavaImp" );
If you encounter problems ensure your CLASS_PATH and PATH are set appropriately for your environment. Please refer to Java Native Interface for further details on using a JNI DLL in java code.
参考原文
http://www.mingw.org/mingwfaq.shtml#faq-jni-dll