gpt4 book ai didi

java - native 库,Java OpenAL 所需

转载 作者:太空宇宙 更新时间:2023-11-04 13:13:57 27 4
gpt4 key购买 nike

我正在尝试使用 Java OpenAL 库。我在导入名为 libsoft_oal.so 的 native 库时遇到问题。 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"); 加载库时一切都按预期进行。这是库中有问题的部分:

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

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

最佳答案

我已经编辑了库,现在一切正常。我还在 GitHub 上创建了一个拉取请求。

关于java - native 库,Java OpenAL 所需,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33702352/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com