Java OpenAL所需的本机库

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

我正在尝试使用Java OpenAL库。我在导入名为libsoft_oal.so的本机库时遇到问题。 Java OpenAL依赖于OpenAL软实现。我尝试根据他们在github上的自述文件来构建它,似乎只编译了libopenal.so库。 Java OpenAL 4年没有更新,所以在我看来,这个库只是被重命名了。我重新命名了图书馆,但没有运气。我认为我的库路径是正确的,我试图用java.library.path参数运行jvm,但没有运气。这是堆栈跟踪:

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.

当我使用System.loadLibrary(“soft_oal”)加载库时; everythinkg按预期工作。这是库中有问题的部分:

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);
    }
}

有没有办法在不直接修改库的情况下解决这个问题?谢谢

java shared-libraries openal openal-soft
1个回答
0
投票

我编辑了图书馆,现在一切正常。我还在GitHub上创建了一个pull请求。

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