• Pavel Galkin's avatar
    ALSA: Fix undefined symbols during static compilation · 8a9ea7ce
    Pavel Galkin authored
    These were undefined when linking with the -static flag on:
    
      1. Alpine Linux v3.21 x86_64
      2. Debian GNU/Linux 12 (bookworm) aarch64
    
    In both cases I had to manually compile alsa-lib as a static library
    because the systems have only .so versions. I did it with:
    
      cd path/to/alsa-libs
      ./gitcompile static
      <this will create alsa-libs/src/.libs/libasound.a>
    
    Tested with alsa-libs 1.12.2 and 1.12.3.
    
    It's possible to reproduce the errors like this:
    
    clang -static -DMA_NO_RUNTIME_LINKING -DMA_ENABLE_ONLY_SPECIFIC_BACKENDS -DMA_ENABLE_ALSA -DMA_DEBUG_OUTPUT -Wall -Wextra -g3 simple_playback_sine.c -o build/miniwave -fcolor-diagnostics -ferror-limit=2 -fuse-ld=lld -I../
    -L/home/antharas/code/alsa-lib/src/.libs/ -lasound
    
    However, even though it compiles I can't verify that everything works.
    
      1. Alpine has musl which doesn't support runtime linking when
         compiling with -static. So even though I disabled it for
         miniaudio.h, libasound.a itself uses dlopen on
         libasound_module_pcm_pipewire.so.
      2. Debian uses glibc so it supports it but fails because my machine is
         a VPS that doesn't have a soundcard.
    
    No big deal, I don't really need to statically link, it was just
    something I stumbled upon.
    
    Also these are currently unused:
    
      _snd_pcm_hw_params_set_rate_minmax
      ma_timer_init
      ma_timer_get_time_in_seconds
      ma_device__on_notification_rerouted
    8a9ea7ce
miniaudio.h 3.86 MB
The source could not be displayed because it is larger than 1 MB. You can load it anyway or download it instead.