dqyym3667 2019-02-19 06:33
浏览 599
已采纳

在Windows上使用JNI从Java调用Golang会导致“动态链接库(DLL)初始化例程失败”

I created the following example project to test out calling Golang code from Java using JNI: https://github.com/blaubaer/golang-jni

When I call build.cmd I receive an error message like this:

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:

  • Windows: 10.0.17763, Build 17763, 64bit
  • Golang: 1.11.5, windows/amd64
  • Java: 11.0.2 2019-01-15 LTS, 64-Bit
  • MinGW-w64: x86_64-8.1.0-win32-sjlj-rt_v6-rev0

Thanks!

  • 写回答

1条回答 默认 最新

  • dre75230 2019-03-21 09:01
    关注

    It seems to be related to a bug inside Golang itself. 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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 C++行情软件的tick数据如何高效的合成K线
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。
  • ¥20 在easyX库下编写C语言扑克游戏跑的快,能实现简单的人机对战