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

I am trying to find a way to get 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 to find how to compile it with g ++ was the following:

 $ g++ test.cpp -lalut 

This results in the following error:

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

Any ideas on how to connect OpenAL to my projects? I spent hours on Google and the answer does not seem to exist. I probably did something fundamentally wrong, as I am new to Linux C ++ development. Thanks.

Edit: modified for reference:

 $ g++ -lalut test.cpp 

to

 $ g++ test.cpp -lalut 

(later this is the correct way to do this, I wrote it incorrectly).

+4
source share
3 answers

Make sure you have a set

 sudo apt-get install libalut-dev 
+7
source

Your error message indicates that your compiler cannot find the header file for ALUT (a utility that makes getting started with OpenAL development easier). This may be for one of two reasons:

  • You have not installed the library at all. In this case, use apt-get install , as you did with OpenAL itself.

  • The header is present somewhere on your system, but not in the default inclusion path. If you can find the library in the file system, be sure to include its include directory, known by g ++, using the -I .

As a rule, when linking to a library using g ++ (or MinGW for what this is important), at compile time, you must be available for the compiler toolchain:

  • There is a directory in the library (where the header files are located) - using -I
  • Library File Directory - Using -L
  • The name of the library file (s) - using -L

Typically, on Linux, the first two types are automatically processed during the installation procedure of the corresponding library package. However, if your library is resting somewhere else than standard directories, you must explicitly specify the include and library path.

For a brief introduction to using g ++, see also here .

Edit: I understand that I spent too much time on my answer, while your problem has already been resolved. But I hope that the above information is useful to you anyway!

+5
source

Gracias busque esta info por todos lados.

En resumen:

sudo apt-get install libasound-dev sudo apt-get install libopenal-dev sudo apt-get install libalut-dev

recuerden incluir la libreria openAL en

Project -> Properties -> C / C ++ Build -> Settings -> Compiler -> Includes

+1
source

All Articles