You are not logged in.
I hacked up a little util in C that makes use of alsa-lib. I can't compile it: I think gcc doesn't find the libraries:
$ gcc foo.c
/tmp/ccc4NH6a.o: In function `mixer_abort':
foo.c:(.text+0x29): undefined reference to `snd_strerror'
foo.c:(.text+0x5f): undefined reference to `snd_strerror'
foo.c:(.text+0xac): undefined reference to `snd_mixer_close'
/tmp/ccc4NH6a.o: In function `mixer_init':
foo.c:(.text+0xc2): undefined reference to `snd_ctl_card_info_sizeof'
foo.c:(.text+0xf1): undefined reference to `snd_ctl_card_info_sizeof'
foo.c:(.text+0x123): undefined reference to `snd_ctl_open'
foo.c:(.text+0x159): undefined reference to `snd_ctl_card_info'
foo.c:(.text+0x188): undefined reference to `snd_ctl_close'
foo.c:(.text+0x19c): undefined reference to `snd_mixer_open'
foo.c:(.text+0x1d5): undefined reference to `snd_mixer_attach'
foo.c:(.text+0x219): undefined reference to `snd_mixer_selem_register'
foo.c:(.text+0x252): undefined reference to `snd_mixer_set_callback'
foo.c:(.text+0x25f): undefined reference to `snd_mixer_load'
/tmp/ccc4NH6a.o: In function `printVolume':
foo.c:(.text+0x2a5): undefined reference to `snd_mixer_selem_get_playback_volume'
collect2: ld returned 1 exit status
I've #included <alsa/asoundlib.h> in foo.c, and I know it gets read, because the typedefs work (if I remove the '#include' line, gcc prints more errors). There's probably a lib file I have to point gcc to; how do I do that? I haven't found the right terms to feed to google.
Last edited by peets (2008-11-01 02:57:11)
Offline
gcc foo.c `pkg-config --libs alsa`
pkg-config can also point to the include files. Use #include <asoundlib.h> and
gcc foo.c `pkg-config --cflags --libs alsa`
Offline
Thank you! I'd tried '-lalsa' and '-lalsa-lib' but I never would have guessed '-lasound'.
Offline