New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.UnsatisfiedLinkError: Unable to load library 'C:\Users\ADMINI~1\AppData\Local\Temp\nativeutils14683980698824\libsodium.dll #34

Closed
MyGodIT opened this Issue Jul 23, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@MyGodIT
Copy link

MyGodIT commented Jul 23, 2018

image
Can you help me about this?
how do for this?

@gurpreet- gurpreet- self-assigned this Jul 23, 2018

@gurpreet- gurpreet- added the stuck label Jul 23, 2018

@gurpreet-

This comment has been minimized.

Copy link
Contributor

gurpreet- commented Jul 23, 2018

Hello @MyGodIT

I can see you're on windows. I need two pieces of information from you:

  1. Is the Windows version 32-bit or 64-bit?
  2. What operating system are you running? Windows 10?

Thanks!

@MyGodIT

This comment has been minimized.

Copy link
Author

MyGodIT commented Aug 3, 2018

Windows7 64-bit

@maxjava44

This comment has been minimized.

Copy link

maxjava44 commented Aug 3, 2018

I have the same issue on Debian Linux(32-bit) too
I tried even running java as root but it shows this Error
java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/nativeutils8886288140120/libsodium.so': Native library (tmp/nativeutils8886288140120/libsodium.so) not found in resource path ([file:/home/max/QuantPass/target/jfx/app/QuantPass-1.0-SNAPSHOT-jfx.jar])
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:303)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427)
at com.sun.jna.Native.register(Native.java:1647)
at com.goterl.lazycode.lazysodium.utils.NativeUtils.loadLibraryFromJar(NativeUtils.java:104)
at com.goterl.lazycode.lazysodium.SodiumJava.registerFromResources(SodiumJava.java:156)
at com.goterl.lazycode.lazysodium.SodiumJava.(SodiumJava.java:21)
at org.maxjava44.quantpass.Main.(Main.java:12)
... 13 more

@gurpreet-

This comment has been minimized.

Copy link
Contributor

gurpreet- commented Aug 4, 2018

Okay so I spun up a Debian virtual machine and dug into the issue a bit further.

Quick fix

A quick fix is to update your OS so that it supports Libsodium 1.0.16. But if you can't update your OS, for whatever reason then you should read the analysis of the issue below.

Analysis

The first thing to note is that Lazysodium supports Libsodium 1.0.16, which means that your operating system must also be updated to provide the underlying architecture that Libsodium 1.0.16 uses. For example, Libsodium is dependent on GLIBC version 2.15 and above. Unfortunately some Linux distros (like Debian 9 and even older versions of Windows) don't support 2.15. You could manually update GLIBC but then again, what about the other Libsodium dependencies? Do you strenuously and haphazardly voyage into the land of updating everything in order to get Libsodium (and therefore Lazysodium) working? Or do you just simply update your operating system threby guaranteeing Libsodium works?

Some solutions

Let's walk through the steps you could try to resolve this.

1. Update your OS

Updating your OS to support the underlying architecture of the Libsodium version you want. This is the easiest and most surefire way of ensuring that this error is caused by your OS and not something else. It isn't the most surefire way of totally getting rid of this error as this error may occur for a number of other reasons.

2. Install/update Libsodium

Run an apt install libsodium if on a Ubuntu-like Linux machine or brew install libsodium if on MacOS or install the .dll file if on Windows to install/update your operating system's Libsodium version. Or perform other steps to install/update Libsodium for your OS version.

I tested running Lazysodium on Debian 9 (Stretch, which is the latest version) and it resulted in the error in the comment above. Looking at the Libsodium package included in Stretch the version of Libsodium it supports is 1.0.11. So to get an updated Libsodium, you have to make sure you manually install it using Stretch backports.

Then all you have to do is call new SodiumJava("sodium") to load Libsodium from the operating system and NOT the bundled one.

3. Use an up-to-date precompiled Libsodium from somewhere

The second method is to just grab a compiled libsodium.so/libsodium.dylib/libsodium.dll with the version that you want. As an example, Debian provides backports which allow you to get future versions of software on older versions of Debian.

Then you can load it into a path that Lazysodium can detect and then you can simply write new SodiumJava("sodium") to instantiate Lazysodium.

Counterpoint: After I did load the new libsodium.so file into Lazysodium it errored with: java.lang.UnsatisfiedLinkError: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.15' not found'. This goes back to my comment earlier regarding Libsodium dependencies, do you continue down this path of updating everything in order to get Libsodium working?

4. Compile it yourself

I've written a guide on how to compile and self-provision Libsodium here. This may or may not work as Libsodium depends on libc.so which needs to be updated to the latest version before compiling Libsodium. You may get an error similar to the one in method 3.

Conclusion

I'm sorry that to get Lazysodium working you need to jump through all of these hoops. Using one of the above methods can surely help you out. By the way Lazysodium has an issue with LD_LIBRARY_PATH not being recognised #36, so keep an eye on that issue if you do want to use that environment variable to add native libraries to your paths.

P.S: Just for the record, this isn't a Lazysodium issue, it's more of a "keeping your OS and its packages up-to-date" kind of issue 😃

@maxjava44

This comment has been minimized.

Copy link

maxjava44 commented Aug 4, 2018

Thanks for your detailed answer i will try a newer distro

@gurpreet-

This comment has been minimized.

Copy link
Contributor

gurpreet- commented Aug 4, 2018

Updated the FAQ section in the docs to reflect this issue that will undoubtedly crop up for a lot of people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment