问题
I am completely new to Open AL. So I started with installing Open AL library through command line
sudo apt-get install libopenal-dev
And also I installed alut installed with this command
sudo apt-get install libalut0 libalut-dev
Also I forked open Al from http://kcat.strangesoft.net/openal.html and installed it also. But when I am trying to compile this simple program:
#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;
}
I am getting this error:
/tmp/cchMpaeS.o: In function main':
altest.cpp:(.text+0xe): undefined reference to
alcOpenDevice'
collect2: error: ld returned 1 exit status
I compiled it with
g++ altest.cpp
g++ -std=c++11 altest.cpp
Both of them gave same error.
回答1:
You need to link to the OpenAl library:
g++ -std=c++11 altest.cpp -lopenal
来源:https://stackoverflow.com/questions/44694002/functions-of-open-al-giving-error-of-undefined-reference-while-compiling-with-g