I'm trying to use Java OpenAL library. I have a problem with importing native library called libsoft_oal.so. Java OpenAL is dependent upon OpenAL soft implementation. I tried to build it according to their readme on github and it seems that only libopenal.so library is compiled. Java OpenAL wasn't updated for 4 years so it seemed to me that the library was simply renamed. I renamed the library but with no luck. I think my library path is correct and I tried to run jvm with java.library.path parameter but with no luck. Here is the stacktrace:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'soft_oal': libsoft_oal.so: cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at org.urish.openal.jna.ALFactory.<init>(ALFactory.java:16)
at org.urish.openal.OpenAL.<init>(OpenAL.java:24)
at defaultpackage.SoundTest.<init>(SoundTest.java:22)
at defaultpackage.SoundTest.main(SoundTest.java:17)
:run FAILED
FAILURE: Build failed with an exception.
When I load the library with System.loadLibrary("soft_oal"); everythinkg works as expected. This is the problematic part in library:
public class ALFactory {
private static final String DEFAULT_DLL_NAME = "soft_oal";
public final AL al;
public final ALC alc;
public final ALExt alext;
public ALFactory() {
al = (AL) Native.loadLibrary(DEFAULT_DLL_NAME, AL.class);
alc = (ALC) Native.loadLibrary(DEFAULT_DLL_NAME, ALC.class);
alext = (ALExt) Native.loadLibrary(DEFAULT_DLL_NAME, ALExt.class);
}
public ALFactory(File dllPath) throws FileNotFoundException {
String dllName = DEFAULT_DLL_NAME;
if (dllPath != null) {
if (!dllPath.exists()) {
throw new FileNotFoundException(dllPath.getAbsolutePath());
}
System.setProperty("jna.library.path", dllPath.getParent());
dllName = dllPath.getName();
}
al = (AL) Native.loadLibrary(dllName, AL.class);
alc = (ALC) Native.loadLibrary(dllName, ALC.class);
alext = (ALExt) Native.loadLibrary(dllName, ALExt.class);
}
}
Is there a way to solve this without directly modifying the library? Thanks
I've edited the library and everything works fine now. I've also created a pull request on GitHub.