我正在使用JNI (Java-Native-Interface)访问一些用c++编写的代码。当我从命令行运行代码时,一切正常,但是当我将代码添加到我的Intellij项目(类、头文件和dll)中时,它给出以下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Robin\Desktop\egdb_example\end.dll: Can't find dependent libraries我的Java代码如下所示:
public class EndGame {
public static native void openDataBase(int maxPieces, int buffer);
public static native void test();
public static native int lookUp(int condition, int BP, int WP, int K, int color);
public static native void close();
static {
System.load("C:\\Users\\Robin\\Desktop\\egdb_example\\end.dll");
}
public static void main(String[] args) {
System.out.println("Kleiner Test");
openDataBase(8, 2000);
int value = lookUp(0, 0, 0, 0, 0);
close();
}
}运行这段代码时,我检查了路径是否正确
File test = new File("C:\\Users\\Robin\\Desktop\\egdb_example");
for (File file : test.listFiles()){
System.out.println(file.getName());
}这会产生结果:
.git
.gitattributes
.gitignore
egdb.h
egdb.lib
egdb64.dll
egdb64.lib
egdb_example.cpp
egdb_example.vcxproj
egdb_example.vcxproj.filters
end.dll
EndGame.class
EndGame.h
EndGame.java
jni.h
jni_md.h
main.cpp
Readme.pdf
robin.cpp
robin.exe会非常感谢任何人的帮助
发布于 2017-04-30 20:57:39
看看这里,看看如何设置IntelliJ和CLion来调试代码。
http://jnicookbook.owsiak.org/recipe-No-D002/
如果您不使用CLion,只需跳过该部分,只看一看IntelliJ配置。
https://stackoverflow.com/questions/43704134
复制相似问题