SDL_sndioaudio.c: 对 `sio_*' 的未定义引用

SDL_sndioaudio.c: undefined reference to `sio_*'

在 Debian stretch 上编译具有 OpenAL 和 SDL2 依赖项的 c++ 项目时遇到问题

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'

我目前已经安装了这些软件包

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

知道我在这里遗漏了什么吗?

解决这个问题的两种可能性

  1. 卸载sndio包

    sudo apt remove libsndio-dev:*

  2. 添加sndiolink标志

    • CMakeLists.txt:在target_link_libraries中添加sndio,使其看起来像
      target_link_libraries(SDL2 sndio)
    • Makefile: 添加-lsndio