Skip to content

Autotools build fails #7

@nurupo

Description

@nurupo

When building using the autotools build system, Alut fails to link against OpenAL installed in a custom directory.

I have followed the instructions from README for how to let Alut know of OpenAL installed in non-system-wide manner, specifically

To build and run ALUT, you need an OpenAL somewhere (and a sound card, of course
:-). If OpenAL is not installed in a standard place (let's say ${OPENAL_PREFIX})
you'll have to tell the build system about it:

CPPFLAGS="-I${OPENAL_PREFIX}/include"
LDFLAGS="-L${OPENAL_PREFIX}/lib"
export CPPFLAGS LDFLAGS

I build OpenAL and Alut on a clean Debian Jessie system like this

# Create a clean Debian Jessie system in a container
sudo docker run -it --rm debian:jessie-slim /bin/bash


# Setup

apt-get update
apt-get install build-essential autoconf cmake libtool pkg-config libpulse-dev libasound2-dev git -y

cd ~

mkdir prefix_openal
cd prefix_openal
OPENAL_DIR=$(pwd)
cd ..

mkdir prefix_alut
cd prefix_alut
ALUT_DIR=$(pwd)
cd ..


# OpenAL

git clone https://github.com/kcat/openal-soft
cd openal*
git checkout openal-soft-1.18.0
cd build

cmake -DCMAKE_INSTALL_PREFIX=$OPENAL_DIR \
      -DCMAKE_BUILD_TYPE=Release \
      -DALSOFT_UTILS=OFF \
      -DALSOFT_EXAMPLES=OFF \
      -DCMAKE_C_FLAGS="-fPIC" \
      -DLIBTYPE=STATIC \
      ..

make
make install

cd ../..


# Alut

git clone https://github.com/vancegroup/freealut
cd freealut

CPPFLAGS="-I${OPENAL_DIR}/include"
LDFLAGS="-L${OPENAL_DIR}/lib"
export CPPFLAGS LDFLAGS

./autogen.sh
./configure --prefix="${ALUT_DIR}" --disable-shared --enable-static

make
make install

The build fails with

Making all in examples
make[2]: Entering directory '/root/freealut/examples'
gcc -DHAVE_CONFIG_H -I. -I..  -I../include -I/root/prefix_openal/include -fvisibility=hidden -g -O2 -MT hello_world.o -MD -MP -MF .deps/hello_world.Tpo -c -o hello_world.o hello_world.c
mv -f .deps/hello_world.Tpo .deps/hello_world.Po
/bin/bash ../libtool  --tag=CC   --mode=link gcc -fvisibility=hidden -g -O2  -L/root/prefix_openal/lib -o hello_world hello_world.o ../src/libalut.la
libtool: link: gcc -fvisibility=hidden -g -O2 -o hello_world hello_world.o  -L/root/prefix_openal/lib ../src/.libs/libalut.a -lm
hello_world.o: In function `main':
/root/freealut/examples/hello_world.c:17: undefined reference to `alGenSources'
/root/freealut/examples/hello_world.c:18: undefined reference to `alSourcei'
/root/freealut/examples/hello_world.c:19: undefined reference to `alSourcePlay'
../src/.libs/libalut.a(libalut_la-alutInit.o): In function `_alutSanityCheck':
/root/freealut/src/alutInit.c:27: undefined reference to `alcGetCurrentContext'
/root/freealut/src/alutInit.c:34: undefined reference to `alGetError'
/root/freealut/src/alutInit.c:40: undefined reference to `alcGetContextsDevice'
/root/freealut/src/alutInit.c:40: undefined reference to `alcGetError'
../src/.libs/libalut.a(libalut_la-alutInit.o): In function `alutInit':
/root/freealut/src/alutInit.c:67: undefined reference to `alcOpenDevice'
/root/freealut/src/alutInit.c:74: undefined reference to `alcCreateContext'
/root/freealut/src/alutInit.c:82: undefined reference to `alcMakeContextCurrent'
/root/freealut/src/alutInit.c:84: undefined reference to `alcDestroyContext'
/root/freealut/src/alutInit.c:85: undefined reference to `alcCloseDevice'
/root/freealut/src/alutInit.c:77: undefined reference to `alcCloseDevice'
../src/.libs/libalut.a(libalut_la-alutInit.o): In function `alutExit':
/root/freealut/src/alutInit.c:136: undefined reference to `alcMakeContextCurrent'
/root/freealut/src/alutInit.c:142: undefined reference to `alcGetContextsDevice'
/root/freealut/src/alutInit.c:143: undefined reference to `alcDestroyContext'
/root/freealut/src/alutInit.c:144: undefined reference to `alcGetError'
/root/freealut/src/alutInit.c:150: undefined reference to `alcCloseDevice'
../src/.libs/libalut.a(libalut_la-alutBufferData.o): In function `generateBuffer':
/root/freealut/src/alutBufferData.c:99: undefined reference to `alGenBuffers'
/root/freealut/src/alutBufferData.c:100: undefined reference to `alGetError'
../src/.libs/libalut.a(libalut_la-alutBufferData.o): In function `passBufferData':
/root/freealut/src/alutBufferData.c:122: undefined reference to `alBufferData'
/root/freealut/src/alutBufferData.c:124: undefined reference to `alGetError'
collect2: error: ld returned 1 exit status
Makefile:348: recipe for target 'hello_world' failed
make[2]: *** [hello_world] Error 1
make[2]: Leaving directory '/root/freealut/examples'

Here is a tree $OPENAL_DIR, just in case you think OpenAL is improperly installed

/root/prefix_openal
|-- bin
|   `-- altonegen
|-- include
|   `-- AL
|       |-- al.h
|       |-- alc.h
|       |-- alext.h
|       |-- efx-creative.h
|       |-- efx-presets.h
|       `-- efx.h
|-- lib
|   |-- cmake
|   |   `-- OpenAL
|   |       |-- OpenALConfig-release.cmake
|   |       `-- OpenALConfig.cmake
|   |-- libopenal.a
|   `-- pkgconfig
|       `-- openal.pc
`-- share
    `-- openal
        |-- alsoftrc.sample
        |-- hrtf
        |   |-- default-44100.mhr
        |   `-- default-48000.mhr
        `-- presets
            |-- 3D7.1.ambdec
            |-- hexagon.ambdec
            |-- itu5.1.ambdec
            |-- presets.txt
            |-- rectangle.ambdec
            `-- square.ambdec

11 directories, 20 files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions