c++ - g++ 无法链接 OpenAL 库

标签 c++ linux g++ openal

我在编译以下代码时遇到了问题

#include <AL/al.h>
#include <AL/alc.h>

#include <iostream>


int checkEnumerationSupport() {

    ALboolean enumeration;

    enumeration = alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT");

    if (enumeration == AL_FALSE) {
        // enumeration not supported
        std::cout << "enumerating devices NOT supported\n";
    } else {
        // enumeration supported
        std::cout << "enumerating devices supported\n";
    };

    return 0;

}


int main() {

    checkEnumerationSupport();

}

使用下面的命令。

g++ test.cpp -o test

我收到以下消息:

/tmp/ccEN7YAp.o: In function `checkEnumerationSupport()':
test.cpp:(.text+0x13): undefined reference to `alcIsExtensionPresent'
collect2: error: ld returned 1 exit status

意识到库链接不正确,我尝试将 g++ 行更改为

g++ -L/usr/lib/ test.cpp -o test -lal -lalc

给我以下信息:

/usr/bin/ld: cannot find -lal
/usr/bin/ld: cannot find -lalc
collect2: error: ld returned 1 exit status

我在 Linux Mint 17.2Ubuntu 14.04 上测试了它。

有谁知道如何正确编译代码?

最佳答案

我们在评论中得出的答案是,Brian 使用 -lopenal 而不是 -lal-lalc 链接到开放库

关于c++ - g++ 无法链接 OpenAL 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32230601/

相关文章:

c++ - Eclipse C++ - 输出到窗口 DOS

c++ - 从 riscv-gnu-toolchain 生成的 s 文件不运行 RISCV 模拟器

java - GLOB 在 Unix/Linux/Java 世界中的缩写是什么?

c++ - 为什么 std atomic 将 5 插入堆栈

c++11 - 如何在 g++ -std=c++11 version 4.8.2 中使用 snprintf()

c++ - 我卡在自定义链表上

c++ - 在 C++11 - 多线程中,我们是否需要互斥锁来访问单例对象中的数据字段?

c - Xlib:如何检查特定窗口是否最小化?

linux - 了解 rpmbuild 的工作原理

c++ - 我正在使用哪个版本的C++?