【问题标题】:g++ unable to link OpenAL Librariesg++ 无法链接 OpenAL 库
【发布时间】:2015-08-26 23:58:15
【问题描述】:

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

#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 上对其进行了测试。

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

【问题讨论】:

  • 你能看到 /usr/lib/ 中的库文件吗?
  • 你试过用-lopenal代替-lal-lalc
  • @timofiend -lopenal 工作,非常感谢。
  • @timofiend 您能否将其发布为答案,以便我可以将此问题标记为已解决?
  • 不用担心 :) 刚刚发布了

标签: c++ linux g++ openal


【解决方案1】:

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

【讨论】:

  • 您介意看看我的另一个问题吗? link
猜你喜欢
  • 1970-01-01
  • 2020-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-16
相关资源
最近更新 更多