无法加载本机 JNI 库

问题描述 投票:0回答:1

我正在开发 Minecraft 库供我自己的 mod 使用,但我遇到了 JNI 问题。

我对 JNI 和 C++ 还很陌生,所以我可能犯了一个错误,但经过几个小时的搜索,我没有找到问题的答案。

每当我尝试加载库时,无论是从绝对路径还是从 jar 内复制到临时目录并从那里加载它,它总是输出以下内容:

java.lang.UnsatisfiedLinkError: E:\IdeaProjects\hmmm library\nativeLibSrc\hmmm.dll: The specified procedure could not be found
    at jdk.internal.loader.NativeLibraries.load(Native Method) ~[?:?]
    at jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388) ~[?:?]
    at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232) ~[?:?]
    at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174) ~[?:?]
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2394) ~[?:?]
    at java.lang.Runtime.load0(Runtime.java:755) ~[?:?]
    at java.lang.System.load(System.java:1953) ~[?:?]
    at dev.progames723.hmmm.utils.NativeUtil.init(NativeUtil.java:107) ~[hmmm-1.0-dev.jar:?]
    at dev.progames723.hmmm.HmmmLibrary.init(HmmmLibrary.java:63) ~[hmmm-1.0-dev.jar:?]
    at dev.progames723.hmmm.fabric.HmmmLibraryFabric.onInitialize(HmmmLibraryFabric.java:9) ~[main/:?]
    at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:384) ~[fabric-loader-0.15.3.jar:?]
    at net.fabricmc.loader.impl.game.minecraft.Hooks.startClient(Hooks.java:52) ~[fabric-loader-0.15.3.jar:?]
    at net.minecraft.client.Minecraft.<init>(Minecraft.java:466) ~[minecraft-merged-ec231b8e98-1.20.2-loom.mappings.1_20_2.layered+hash.668605046-v2.jar:?]
    at net.minecraft.client.main.Main.main(Main.java:214) ~[minecraft-merged-ec231b8e98-1.20.2-loom.mappings.1_20_2.layered+hash.668605046-v2.jar:?]
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470) ~[fabric-loader-0.15.3.jar:?]
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) ~[fabric-loader-0.15.3.jar:?]
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) ~[fabric-loader-0.15.3.jar:?]
    at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) ~[dev-launch-injector-0.2.1+build.8.jar:?]
    at dev.architectury.transformer.TransformerRuntime.main(TransformerRuntime.java:220) ~[architectury-transformer-5.2.87-runtime.jar:?]

库的源代码:https://github.com/Progames723/Hmmm/tree/master/nativeLibSrc/src/main

我尝试将编译器参数更改为我找到的参数,但它们从未做过任何有意义的事情。

java c++ java-native-interface
1个回答
0
投票

遇到 JNI 问题时,我尝试的第一件事是检查 DLL 是否具有所有可用的依赖项。

查看 https://download.cnet.com/dependency-walker-64-bit/3000-2086_4-75785868.htmlhttps://www.dependencywalker.com/ 并检查 DLL好。

© www.soinside.com 2019 - 2024. All rights reserved.