【发布时间】: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.2 和 Ubuntu 14.04 上对其进行了测试。
有人知道如何正确编译代码吗?
【问题讨论】:
-
你能看到 /usr/lib/ 中的库文件吗?
-
你试过用
-lopenal代替-lal和-lalc -
@timofiend -lopenal 工作,非常感谢。
-
@timofiend 您能否将其发布为答案,以便我可以将此问题标记为已解决?
-
不用担心 :) 刚刚发布了