[Pkg-alsa-devel] Bug#944655: libasound2-dev: Cannot link to C++ using GCC 9

Paul Martin pm at debian.org
Wed Nov 13 11:18:10 GMT 2019


Package: libasound2-dev
Version: 1.1.9-1
Severity: important

Attached is a trivial ALSA program written in C++ which links when built 
with GCC older than 9 or any available version of clang, but fails at 
the link stage when using GCC 9.2.1:

$ make
g++-9    -c -o testprog.o testprog.cpp
g++-9 -lasound -o testprog testprog.o
/usr/bin/ld: testprog.o: in function `main':
testprog.cpp:(.text+0x29): undefined reference to `snd_pcm_open'
/usr/bin/ld: testprog.cpp:(.text+0x3e): undefined reference to `snd_pcm_close'
collect2: error: ld returned 1 exit status
make: *** [Makefile:4: testprog] Error 1




-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.3.0-2-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8), LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libasound2-dev depends on:
ii  libasound2  1.1.9-1

libasound2-dev recommends no packages.

Versions of packages libasound2-dev suggests:
pn  libasound2-doc  <none>

-- no debconf information
-------------- next part --------------
CXX=g++-9

testprog: testprog.o
	$(CXX) -lasound -o $@ $^

clean:
	-rm -f testprog.o testprog
-------------- next part --------------
#include "alsa/asoundlib.h"

int main() {
    snd_pcm_t *pcm = nullptr;

    int ret = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK, 0);
    if (!ret) {
        snd_pcm_close(pcm);
    }

    return 0;
}


More information about the Pkg-alsa-devel mailing list