g ++无法链接OpenAL库 [英] g++ unable to link OpenAL Libraries
问题描述
我在编译以下代码时遇到困难
#include< AL / al.h>
#include< AL / alc.h>
#include< iostream>
int checkEnumerationSupport(){
ALboolean枚举;
enumeration = alcIsExtensionPresent(NULL,ALC_ENUMERATION_EXT);
if(枚举== AL_FALSE){
//枚举不支持
std :: cout<< 枚举设备不支持\ n;
} else {
//支持的枚举
std :: cout<< 列举支持的设备;
};
返回0;
$ b int main(){
checkEnumerationSupport();
}
使用下面的命令。
g ++ test.cpp -o test
/tmp/ccEN7YAp.o:在函数checkEnumerationSupport()中:
test.cpp :(。text + 0x13):未定义引用'alcIsExtensionPresent'
collect2:错误:ld返回1退出状态
实现库链接不正确,我尝试将g ++行更改为
g ++ -L / usr / lib / test.cpp -o test -lal -lalc
给我以下消息:
$ p $ / usr / bin / ld:找不到-lal
/ usr / bin / ld:找不到-lalc
collect2:error:ld返回1退出状态
我测试过它 Linux Mint 17.2 和 Ubuntu 14.04 。
有谁知道如何正确编译代码?
我们在评论中提出的答案是让Brian使用 -lopenal
链接到openal库 -lal
和 -lalc
I have trouble compiling the following code
#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();
}
using the command below.
g++ test.cpp -o test
I get the following message:
/tmp/ccEN7YAp.o: In function `checkEnumerationSupport()':
test.cpp:(.text+0x13): undefined reference to `alcIsExtensionPresent'
collect2: error: ld returned 1 exit status
Realising the libraries weren't linked correctly, I tried changing the g++ line to
g++ -L/usr/lib/ test.cpp -o test -lal -lalc
giving me the following message:
/usr/bin/ld: cannot find -lal
/usr/bin/ld: cannot find -lalc
collect2: error: ld returned 1 exit status
I tested it on Linux Mint 17.2 and Ubuntu 14.04.
Does anyone know how to compile the code correctly?
The answer, that we worked out in the comments, was for Brian to link to the openal library using -lopenal
instead of -lal
and -lalc
这篇关于g ++无法链接OpenAL库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!