Open AL 的函数在 ubuntu 中使用 g++ 编译时给出未定义引用的错误
Functions of Open AL giving error of undefined reference while compiling with g++ in ubuntu
我是Open AL的新手。所以我开始通过命令行安装 Open AL 库
sudo apt-get install libopenal-dev
我还安装了使用此命令安装的alut
sudo apt-get install libalut0 libalut-dev
我也从 http://kcat.strangesoft.net/openal.html 中分叉开了艾尔并安装了它。但是当我尝试编译这个简单的程序时:
#include <stdio.h>
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alut.h>
int main(){
ALCdevice *device;
device=alcOpenDevice(NULL);
if(!device)
{
printf("no device found");
}
else
{
printf("device found");
}
return 0;
}
我收到此错误:
/tmp/cchMpaeS.o: In function main':
altest.cpp:(.text+0xe): undefined reference to
alcOpenDevice'
collect2:错误:ld 返回 1 个退出状态
我编译了它
g++ altest.cpp
g++ -std=c++11 altest.cpp
他们都给出了同样的错误。
你需要链接到 OpenAl 库:
g++ -std=c++11 altest.cpp -lopenal
相关文章:
- 编译C++时未定义的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- C++ 中的编译错误:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 在编译它时显示未定义的引用
- 编译问题:在函数"_start"中:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 编译 libfluid 样本控制器时对"event_base_del_virtual"的未定义引用
- libssh 问题编译问题未定义的错误
- 为什么我的C++代码无法编译,出现未定义的引用错误
- 为什么更改包含 psapi.h 的顺序会产生编译错误?(标识符 BOOL 未定义)
- 编译为目标 wasm 时未定义的符号
- 在VSCode中编译C++给了我一个未定义的参考
- 在 Linux 上编译 - 在函数 '_start' 中:(.text+0x20):对 'main' 的未定义引用
- 在Linux/Ubuntu中编译openCV应用程序时,如何解决未定义的引用cv:..?
- 使用 Android NDK 使用 clang++ 编译C++代码时对"_Unwind_Resume"的未定义引用
- C 用Python.h编译未定义的符号
- gtkmm3 示例未编译(未定义的引用)
- glfw3 编译未定义的引用
- C ++并且无法编译 - 未定义对'boost::system::generic_category()的引用