我创建了以下示例项目来测试使用 JNI 从 Java 调用 Golang 代码:https ://github.com/blaubaer/golang-jni
当我打电话时,build.cmd我收到如下错误消息:
Exception in thread "main" java.lang.UnsatisfiedLinkError: [...]\out\hello.dll: A dynamic link library (DLL) initialization routine failed
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2649)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
at java.base/java.lang.System.loadLibrary(System.java:1867)
at Hello.<clinit>(Hello.java:3)
使用环境:
Windows:10.0.17763,内部版本 17763,64 位
Golang:1.11.5,windows/amd64
Java:11.0.2 2019-01-15 LTS,64 位
MinGW-w64:x86_64-8.1.0-win32-sjlj-rt_v6-rev0
谢谢!