[英]Calling Golang from Java using JNI on Windows leads to “A dynamic link library (DLL) initialization routine failed”
I created the following example project to test out calling Golang code from Java using JNI: https://github.com/blaubaer/golang-jni 我创建了以下示例项目,以测试使用JNI从Java调用Golang代码: https : //github.com/blaubaer/golang-jni
When I call build.cmd
I receive an error message like this: 当我调用
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)
Used environment: 使用环境:
Thanks! 谢谢!
It seems to be related to a bug inside Golang itself. 它似乎与Golang内部的错误有关。 There is currently a Pull Request opened runtime: This change modifies Go to fix c-shared dll crash on x64 windows #30944 where I can approve that this will fix the issue.
当前有一个“拉取请求”打开的运行时:此更改修改了Go以修复x64 Windows#30944上的c共享dll崩溃,在这里我可以批准它可以解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.