我正在尝试使用swig为java生成c ++库。到目前为止,一切似乎都运行良好,但我收到了错误。
这是我的java代码
package Test;
public class Tester {
static{
System.loadLibrary("example");
}
public static void main(String[] args) {
System.out.println(example.fact(5));
}
}
这是错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.exampleJNI.fact(I)I
at Test.exampleJNI.fact(Native Method)
at Test.example.fact(example.java:22)
at Test.Tester.main(Tester.java:9)
以下是我用于Swig的命令
swig -c++ -java example.i
g++ -c example.cpp example_wrap.cxx -I "C:\Program Files (x86)\Java\jdk1.8.0_92\include" -I "C:\Program Files (x86)\Java\jdk1.8.0_92\include\win32"
g++ -shared example.o example_wrap.o -o example.dll -Wl,--kill-at -I "C:\Program Files (x86)\Java\jdk1.8.0_92\include" -I "C:\Program Files (x86)\Java\jdk1.8.0_92\include\win32"