3

I am trying to cross compile ALSA Lib application for linux-arm based processor. I am using eclipse to do the build for me. The build phase of the application is successful but I get errrors when the gcc linker tries to complete.

I get the following errors

Building target: sound Invoking: Cross GCC Linker arm-linux-gnueabihf-gcc -L/proc/asound -L/srv/nfs/rootfs/usr/lib -Wl,-rpath-link,/srv/nfs/rootfs/usr/lib -L/srv/nfs/rootfs/lib -Wl,-rpath-link,/srv/nfs/rootfs/lib -o "sound" ./play.o
./play.o: In function main': /home/neonws/sound/Debug/../play.c:13: undefined reference tosnd_pcm_open' makefile:29: recipe for target 'sound' failed /home/neonws/sound/Debug/../play.c:14: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:20: undefined reference tosnd_pcm_hw_params_malloc' /home/neonws/sound/Debug/../play.c:21: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:26: undefined reference tosnd_pcm_hw_params_any' /home/neonws/sound/Debug/../play.c:27: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:32: undefined reference tosnd_pcm_hw_params_set_access' /home/neonws/sound/Debug/../play.c:33: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:38: undefined reference tosnd_pcm_hw_params_set_format' /home/neonws/sound/Debug/../play.c:39: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:44: undefined reference tosnd_pcm_hw_params_set_rate_near' /home/neonws/sound/Debug/../play.c:45: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:50: undefined reference tosnd_pcm_hw_params_set_channels' /home/neonws/sound/Debug/../play.c:51: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:56: undefined reference tosnd_pcm_hw_params' /home/neonws/sound/Debug/../play.c:57: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:62: undefined reference tosnd_pcm_hw_params_free' /home/neonws/sound/Debug/../play.c:64: undefined reference to snd_pcm_prepare' /home/neonws/sound/Debug/../play.c:65: undefined reference tosnd_strerror' /home/neonws/sound/Debug/../play.c:71: undefined reference to snd_pcm_writei' /home/neonws/sound/Debug/../play.c:72: undefined reference tosnd_strerror' /home/neonws/sound/Debug/../play.c:78: undefined reference to `snd_pcm_close' collect2: error: ld returned 1 exit status make: *** [sound] Error 1

11:15:58 Build Finished (took 75ms)

I am using the Sample Playback Program from ASLA-LIB api.

I am wondering what is causing the linker to fail?

1 Answers1

3

You're missing an asound library linkage, add -lasound to your linking flags (see this question which tells where to do that properly in Eclipse). And probably remove -L/proc/asound, I don't think you have your libraries there.

Community
  • 1
  • 1
Roman Khimov
  • 4,807
  • 1
  • 27
  • 35
  • >Building target: sound Invoking: Cross GCC Linker arm-linux-gnueabihf-gcc -L/home/alsa-lib-1.1.2/include -L/srv/nfs/rootfs/usr/lib -Wl,-rpath-link,/srv/nfs/rootfs/usr/lib -L/srv/nfs/rootfs/lib -Wl,-rpath-link,/srv/nfs/rootfs/lib -o "sound" ./play.o -lasound /home/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lasound makefile:29: recipe for target 'sound' failed collect2: error: ld returned 1 exit status make: *** [sound] Error 1 14:18:14 Build Finished (took 76ms) – JavaProgrammer Sep 19 '16 at 18:20
  • Hi @Roman I followed the directions you suggested and it giving me a linker errors saying "-lasound not found" Can you please suggest a solution to this. I added "asound" to Libraries(-l) followed by the path in Library search path(-L) for the Linker. – JavaProgrammer Sep 19 '16 at 18:25
  • @JavaProgrammer: it's hard to tell where your libraries are, now you're missing the library in your library search paths, you should add proper path with `-L` parameter. Where do you have your target root file system? – Roman Khimov Sep 19 '16 at 18:45