Search code examples
referenceheaderundefinedopenal

SDL_sndioaudio.c: undefined reference to `sio_*'


I'm facing a problem when compiling a c++ project with OpenAL and SDL2 dependencies on Debian stretch

libs/openal/libopenal.a(sndio.c.o): In function `sndio_stop_playback':
sndio.c:(.text+0x4b): undefined reference to `sio_stop'
libs/openal/libopenal.a(sndio.c.o): In function `sndio_start_playback':
sndio.c:(.text+0xcf): undefined reference to `sio_start'
sndio.c:(.text+0x15c): undefined reference to `sio_stop'
libs/openal/libopenal.a(sndio.c.o): In function `sndio_proc':
sndio.c:(.text+0x278): undefined reference to `sio_write'
libs/openal/libopenal.a(sndio.c.o): In function `sndio_reset_playback':
sndio.c:(.text+0x312): undefined reference to `sio_initpar'
sndio.c:(.text+0x388): undefined reference to `sio_setpar'
sndio.c:(.text+0x3e7): undefined reference to `sio_getpar'
libs/openal/libopenal.a(sndio.c.o): In function `sndio_close_playback':
sndio.c:(.text+0x61e): undefined reference to `sio_close'
libs/openal/libopenal.a(sndio.c.o): In function `sndio_open_playback':
sndio.c:(.text+0x6af): undefined reference to `sio_open'
../libs/sdl2/build/.libs/libSDL2.a(SDL_sndioaudio.o): In function `load_sndio_syms':
SDL_sndioaudio.c:(.text+0xf): undefined reference to `sio_open'
SDL_sndioaudio.c:(.text+0x1b): undefined reference to `sio_close'
SDL_sndioaudio.c:(.text+0x27): undefined reference to `sio_setpar'
SDL_sndioaudio.c:(.text+0x33): undefined reference to `sio_getpar'
SDL_sndioaudio.c:(.text+0x3f): undefined reference to `sio_start'
SDL_sndioaudio.c:(.text+0x4b): undefined reference to `sio_stop'
SDL_sndioaudio.c:(.text+0x57): undefined reference to `sio_read'
SDL_sndioaudio.c:(.text+0x63): undefined reference to `sio_write'
SDL_sndioaudio.c:(.text+0x6f): undefined reference to `sio_initpar'

I currently have those packages installed

libglu1-mesa-dev
libalut0
libalut-dev
libsndio-dev
libroar-dev
libpulse-dev
portaudio19-dev

Any idea of what I'm missing here ?


Solution

  • Two possibilities to fix that

    1. Uninstall sndio package

      sudo apt remove libsndio-dev:*

    2. Add sndio link flag

      • CMakeLists.txt: add sndio in target_link_libraries so that it looks like
        target_link_libraries(SDL2 sndio)
      • Makefile: add -lsndio