JnCrMx / discord-game-sdk4j

Java bindings for Discord's Game SDK
MIT License
114 stars 24 forks source link

java.lang.UnsatisfiedLinkError: Can't find dependent libraries #7

Closed psyvern closed 3 years ago

psyvern commented 3 years ago

I downloaded the examples directory and imported the v0.3 jar through gradle. I ran the ActivityManager example and the program crashed with the following:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\____\AppData\Local\Temp\nativeutils7090437070900\discord_game_sdk_jni.dll: Can't find dependent libraries
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2407)
    at java.base/java.lang.Runtime.load0(Runtime.java:747)
    at java.base/java.lang.System.load(System.java:1857)
    at cz.adamh.utils.NativeUtils.loadLibraryFromJar(NativeUtils.java:109)
    at de.jcm.discordgamesdk.Core.init(Core.java:45)
    at examples.ActivityExample.main(ActivityExample.java:25)

I suspect this is happening because i'm missing a header file in my computer, but i don't know what file.

JnCrMx commented 3 years ago

Hmm... this exception is not because of a missing header file (you don't need header files for already compiled library). It is probably caused by the Discord SDK library not loaded correctly.

I also made a minimal working example (at least it works on my machine), I will attach it as a zip, so you might try to extract and run it. Maybe there is something wrong about your build.gradle, so please try it with mine.

DiscordSDKTest.zip

psyvern commented 3 years ago

I tried your example and it still gives the same result. Also, i tried stopping right before the .dll is read, and both of the temporary directories are where they're supposed to be. I also tried running the code with a new user, but it still throws an exception

JnCrMx commented 3 years ago

Ok, I will try to run it on a clean VM to see if I can replicate the error.

Which version of Java are you using?

JnCrMx commented 3 years ago

I think I figured out the issue. The dll I made requires two additional libraries: A debug library that is most likely caused by a mistake of mine and the other is vcruntime140d.dll (d stands for debug which is my mistake).

I will try to fix this issue as soon as possible.

JnCrMx commented 3 years ago

I've made a new release (0.3.1) which doesn't use Debug builds anymore and works on my VM. I hope that it works on your machine too now ^^

And thank you a lot for reporting this issue. I wouldn't have noticed it by myself 👍

psyvern commented 3 years ago

Yes, it is working now. Thank you!