How to compile OpenAL program with g++ (Ubuntu)?

Sefu picture Sefu · Mar 16, 2013 · Viewed 7.5k times · Source

I am trying to find a way of getting OpenAL to work on my computer:

Ubuntu 12.10 (running on 2010 intel i7 Macbook Pro)

I installed the OpenAL library from the terminal:

$ sudo apt-get install libopenal-dev

Everything went well. Now I tried to create a simple C++ program where I include the library:

#include <iostream>
#include <AL/alut.h>

using namespace std;

int main(){
    cout << "Hello, world" << endl;
}

No matter how hard I tried, the closest I came to finding how to compile it with g++ was:

$ g++ test.cpp -lalut 

This gives the following error:

test.cpp:2:21: fatal error: AL/alut.h: No such file or directory
compilation terminated.

Any ideas on how to get OpenAL linked to my projects? I spent hours on Google and the answer doesn't seem to exist. I probably did something fundamentally wrong, since I'm fairy new to Linux c++ development. Thanks.

Edit: changed for reference:

$ g++ -lalut test.cpp

to

$ g++ test.cpp -lalut

(the later is the correct way of doing it, I posted it wrong).

Answer

Jacob Parker picture Jacob Parker · Mar 16, 2013

Make sure you have alut installed

sudo apt-get install libalut-dev