如何构建JNI .dll? [英] How to build JNI .dll?
本文介绍了如何构建JNI .dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JNI代码是跨平台 - 适用于Windows和Linux。如何建立一个dll?
谢谢。
解决方案
你必须为Windows和.so为Linux构建.DLL。您将使用以下语法在Linux中编译C代码:
gcc -shared yourcode.c -I / usr / lib / gcc / x86_64-redhat-linux / 3.4.3 / include / -o yourLib.so
static {
System.out.println(System.getProperty(java.library.path));
System.loadLibrary(yourlib);
}
对于Windows 如何编译C到DLL
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
这篇关于如何构建JNI .dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文