Have a version of libflac that installs a pkg-config file
Build SDL_mixer the way we do in Debian:
Autotools build
--enable-music-flac-libflac
--disable-music-flac-libflac-shared so that we rely on traditional static or dynamic linking rather than dlopen()
Try to build the project in cmake/test/ with -DTEST_STATIC=ON (the default)
(The same problem probably exists for dependencies other than libflac, I haven't tried.)
Expected result: main_shared is linked statically, as far as is possible.
Actual result:
[3/4] Linking C executable main_static
FAILED: main_static
: && /usr/bin/cc CMakeFiles/main_static.dir/main.c.o -o main_static /usr/lib/x86_64-linux-gnu/libSDL2.a /usr/lib/x86_64-linux-gnu/libSDL2_mixer.a -lm -ldl -lasound -lm -ldl -lpthread -lpulse-simple -pthread -lpulse -pthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXfixes -lXrandr -lXss -lXxf86vm -ldrm -lgbm -lwayland-egl -lwayland-client -lwayland-cursor -lxkbcommon -ldecor-0 -lpthread -lrt && :
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libSDL2_mixer.a(music_flac.o): undefined reference to symbol 'FLAC__stream_decoder_get_total_samples'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libFLAC.so.8: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[4/4] Linking C executable main_shared
I think this is because configure.ac has two code paths for mandatory dependencies:
if found via pkg-config: add to PC_REQUIRES, which ends up in SDL2_mixer.pcRequires.private but is not mentioned in sdl2_mixer-config.cmake
else: add to PC_LIBS, which ends up in SDL2_mixer.pcLibs.private and in sdl2_mixer-config.cmake_sdl2mixer_extra_static_libraries
SDL_image and SDL_ttf do not have this bug: they add mandatory dependencies to IMG_LIBS or TTF_LIBS as appropriate, and sdl2_foo-config.cmake lists both PC_LIBS and IMG_LIBS or TTF_LIBS in its extra_static_libraries variable.
To reproduce:
--enable-music-flac-libflac
--disable-music-flac-libflac-shared
so that we rely on traditional static or dynamic linking rather thandlopen()
cmake/test/
with-DTEST_STATIC=ON
(the default)(The same problem probably exists for dependencies other than libflac, I haven't tried.)
Expected result:
main_shared
is linked statically, as far as is possible.Actual result:
I think this is because
configure.ac
has two code paths for mandatory dependencies:PC_REQUIRES
, which ends up inSDL2_mixer.pc
Requires.private
but is not mentioned insdl2_mixer-config.cmake
PC_LIBS
, which ends up inSDL2_mixer.pc
Libs.private
and insdl2_mixer-config.cmake
_sdl2mixer_extra_static_libraries
SDL_image and SDL_ttf do not have this bug: they add mandatory dependencies to
IMG_LIBS
orTTF_LIBS
as appropriate, andsdl2_foo-config.cmake
lists bothPC_LIBS
andIMG_LIBS
orTTF_LIBS
in itsextra_static_libraries
variable.