libsodium-jni icon indicating copy to clipboard operation
libsodium-jni copied to clipboard

Provide native libraries inside a jar?

Open netvl opened this issue 6 years ago • 2 comments

Many projects provide native libraries inside their jar files, e.g. Netty or LWJGL. However, libsodium-jni does not provide it - apparently, .so files are only present in the AAR package, but not in the regular JAR library. Moreover, it looks like that x86_64 shared object from the AAR file is not usable directly on a regular Linux system:

./libsodiumjni.so: error while loading shared libraries: /usr/lib/libc.so: invalid ELF header

(at least on my system, /usr/libc/libc.so is a textual stub; the proper library is /usr/libc/libc.so.6)

Therefore, there is no simple way to use the library - there is a need to compile the library manually and also add the compiled files to the project by hand. Is it possible to fix this?

netvl avatar Jan 02 '18 17:01 netvl

This is possible, though would prefer to package it according to some well adopted practice regarding the packaging and location of the shared object files inside the jar.

Android Archive Library (AAR) is packaged according to the Android requirements.

Are there any well known requirements or practices regarding packaging the shared objects in jar? Links? Pull requests are welcome as well.

Also, we would package this as a third dependency jar.

joshjdevl avatar Jan 02 '18 21:01 joshjdevl

Also, Java 8 supports loading static libraries. I wonder that might fix the path issue mentioned and that's bound to happen.

http://openjdk.java.net/jeps/178

The static library is located in

./libsodium/libsodium-host/lib/

joshjdevl avatar Jan 03 '18 09:01 joshjdevl