cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Doesn't work with target x86_64-unknown-linux-musl

Open deade1e opened this issue 8 months ago • 0 comments

Hello,

I tried to build a static version of my project by using the aforementioned Rust target and there is no way to make it compile, as it doesn't find asound library (static version).

I tried on ubuntu and then alpine linux (which uses musl by default). Nothing can be done.

I then was able to compile it on NixOS with this specific shell.nix:

{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell {
  buildInputs = with pkgs; [
    # static cross-compilation tools
    pkgsStatic.stdenv.cc

    # ALSA libraries for musl.. yes pkgsStatic often means musl
    pkgsStatic.alsa-lib
    pkgsStatic.alsa-lib.dev
    pkgsStatic.pkg-config
  ];

  shellHook = ''
    export PKG_CONFIG_ALLOW_CROSS=1
    export PKG_CONFIG_PATH="${pkgs.pkgsStatic.alsa-lib.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
    export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER="${pkgs.pkgsStatic.stdenv.cc}/bin/x86_64-unknown-linux-musl-cc"
  '';
}

But then when running the application the following output is what I get:

./target/x86_64-unknown-linux-musl/release/aemt ../ape_escape_ntsc/ play 10 77                                                                                                         
ALSA lib pcm.c:2713:(snd_pcm_open_conf) Either /nix/store/lwmv9vlbhmnj4bvd7y7bwxnhfbwbwzi6-pipewire-1.4.2/lib/alsa-lib/libasound_module_pcm_pipewire.so cannot be opened or _snd_pcm_pipewire_open was not defined in
side                                                                                                                                                                                                                 
                                                                                                                                                                                                                     
thread 'main' panicked at src/commands/play.rs:96:57:                                                                                                                                                                
called `Result::unwrap()` on an `Err` value: BackendSpecific { err: BackendSpecificError { description: "ALSA function 'snd_pcm_open' failed with error 'No such device or address (6)'" } }                         
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This happens when in my code I try to create the stream.

If the project is built using the -gnu target everything is fine.

The project using the library is the following: https://github.com/pfrankw/aemt

Thank you

deade1e avatar Jun 08 '25 11:06 deade1e