3

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 toalcOpenDevice'

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.

Souravirus
  • 301
  • 2
  • 14
  • If you tried something, and you have issue with it, please post what you tried. In this case you tried to compile your program ,but you have not posted the commands you used when you tried that. So post that command. – nos Jun 22 '17 at 08:24
  • @nos I have edited the question – Souravirus Jun 22 '17 at 08:37

1 Answers1

2

You need to link to the OpenAl library:

g++ -std=c++11 altest.cpp -lopenal
nos
  • 223,662
  • 58
  • 417
  • 506