How do I compile OpenAL from CVS?
Written by Jonas   
Tuesday, 10 January 2006

The OpenAL library is responsible for generating spatial (3D) audio. On Windows, there is a well-maintained version of OpenAL (see download area). The Linux version has unfortunately often proven to be lagging behind. As if that weren't enough, distributions tend to include older versions of the library.

This article is currently out of date, as the OpenALteam has switched to subversion.


Pulling from CVS

So if we want to have the most up-to-date version of OpenAL, we have to pull it directly from CVS and compile it ourselves. This is done with the following commands:
$ cvs -d:pserver: This e-mail address is being protected from spam bots, you need JavaScript enabled to view it :/usr/local/cvs-repository login
(when you are asked for a password, enter "guest")
$ cvs -d:pserver: This e-mail address is being protected from spam bots, you need JavaScript enabled to view it :/usr/local/cvs-repository co portable
This will pull the most recent version ("HEAD") from OpenAL's central CVS server. As this is the development branch of OpenAL, there might be problems compiling the package. If you wish to get a specific known-to-work version, you should specify a tag, e.g.:
$ cvs -d:pserver: This e-mail address is being protected from spam bots, you need JavaScript enabled to view it :/usr/local/cvs-repository co -r Linux_Spec1-0 portable
Here are the relevant current CVS tags (copied from the OpenAL homepage):
  • HEAD contains the latest 1.1 code for all implementations (not guaranteed buildable or complete)
  • Linux_Spec1-0 for the last Linux code before the transition towards OpenAL 1.1 began
  • MacOSX1-2_Spec1-0 for the last MacOS X code before the transition towards OpenAL 1.1 began
  • Win1-1-2_Spec1-0 for the last Windows code before the transition towards OpenAL 1.1 began
  • MACOSX_DevelopmentBranch for the OS X development branch
You can either pull portable as in the commands above, or openal. The former is a subset of the OpenAL distribution with only the files relevant for compiling on UNIX-like systems (Linux, Solaris, MacOS X). This FAQ relates to portable.

Compiling OpenAL
Aftern downloading has (hopefully) succeeded, the first step will be to compile OpenAL:
$ cd portable
$ ./autogen.sh
This is quite likely to produce a lot of warning messages, but in the end you should have a new file configure in the current directory. It is used to specify compilation options. This is what I used:
$ CFLAGS="-O2 -g -mmmx" ./configure --disable-shared --enable-static --enable-sdl --enable-alsa --disable-arts --disable-bsd --disable-esd --disable-irix --enable-linux --disable-morphos --disable-solaris --disable-windows --disable-mp3 --disable-vorbis
It is important to include the -mmmx flag (yes, that's 3 'm's) when compiling for PCs. Else, OpenAL might be built without special optimizations and you'll experience slowdowns when many sound sources are audible. The configure script generates a bunch of Makefiles for us, so we can start compilation the usual way:
$ make
As we were building a static version of the OpenAL library, there is no need to do make install afterwards. To get it included in a Thunder&Lightning build, you just pass the library's path (portable/src/.libs/libopenal.so) as the argument of --with-openal-libs to Thunder&Lightning's configure script.


Troubleshooting
You might experience the following error during make:
/bin/sh ../../../libtool --mode=link gcc  -O2 -g -mmmx -msse -msse2   -o libx86_asm_routines.la   x86_cpu_caps_detect_prk.lo memcpy_mmx_prk.lo  -ldl
rm -fr  .libs/libx86_asm_routines.la
ar cru .libs/libx86_asm_routines.a  x86_cpu_caps_detect_prk.o memcpy_mmx_prk.o
ar: x86_cpu_caps_detect_prk.o: No such file or directory
make[4]: *** [libx86_asm_routines.la] Fehler 1
make[4]: Leaving directory `/home/jonas/src/portable/src/arch/i386'
make[3]: *** [all-recursive] Fehler 1
make[3]: Leaving directory `/home/jonas/src/portable/src/arch'
make[2]: *** [all-recursive] Fehler 1
make[2]: Leaving directory `/home/jonas/src/portable/src'
make[1]: *** [all-recursive] Fehler 1
make[1]: Leaving directory `/home/jonas/src/portable'
make: *** [all] Fehler 2
This is caused by an erroneous Makefile. This is a workaround:
$ cd src/arch/i386/
$ make x86_cpu_caps_detect_prk.o
$ make memcpy_mmx_prk.o
$ cd ../../..
$ make
You might also experience this error:
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../common/include -I../include -I../src/arch/i386 -Wall -ansi -pedantic -finline-functions -ffast-math -fomit-frame-pointer -fvisibility=hidden -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=199309 -pthread -I/usr/include/alsa -I/usr/include/SDL -D_REENTRANT -O2 -g -mmmx -msse -msse2 -MT libopenal_la-al_buffer.lo -MD -MP -MF .deps/libopenal_la-al_buffer.Tpo -c al_buffer.c -o libopenal_la-al_buffer.o
In file included from al_buffer.c:14:
../include/AL/alext.h:97: error: syntax error before 'ALfloat'
../include/AL/alext.h:97: warning: type defaults to 'int' in declaration of 'alcGetAudioChannel_LOKI'
../include/AL/alext.h:97: warning: data definition has no type or storage class
../include/AL/alext.h:98: error: syntax error before 'void'

(... lots and lots more errors ...)
It is caused by wrongly including old OpenAL headers installed on your system. To fix it, you have to call configure again. But this time, add -I../../include to the CFLAGS.
Last Updated ( Wednesday, 22 August 2007 )