I am trying to play audio using ALSA Lib on iMX6 running Linux. I am using the Minimal Playback Program mentioned here. I am able to compile the program but the Cross GCC Linker gave me linker errors. After researching about the linking errors, I found out that I need to add -lasound to the linker flags.
After adding the linker flag I am still having errors. The console output is as follows:
16:21:06 **** Incremental Build of configuration Debug for project sound ****
make all
/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
Building target: sound
Invoking: Cross GCC Linker
collect2: error: ld returned 1 exit status
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
makefile:29: recipe for target 'sound' failed
make: *** [sound] Error 1
16:21:06 Build Finished (took 159ms)
Can someone help me resolve this error?
Also, are there any LGPL licensed libraries that could be used for audio playback functionality ?
The sysroots variable in the above Makefile points to the SDK generated from OpenEmbedded. I used this sample code to test audio playback of wav file on Colibri iMX6.
If you use the binary image to link against (and your buildmachine’s header file) then you would need to create unversioned symlinks to the shared libraries as described here.
I.e. you have to execute the following excerpt:
cd /srv/nfs/rootfs/usr/lib
sudo sh -c "ls -w 1 | grep '\.so\.[0-9]*\.[0-9]*\.[0-9]*$' | sed -r 's/(.*\.so)(\.[0-9]*\.[0-9]*\.[0-9]*$)/ln -s \1\2 \1/' > makesymlinks.sh"
sudo chmod +x makesymlinks.sh
sudo ./makesymlinks.sh
sudo rm makesymlinks.sh
Hi Max.
I have created the symlink before and was still getting the error.
I decided to go with the other approach of using SDK. I run the environment_sourcing script and created a symlink to the sysroot found in the sdk package. The linker still gives the error “cannot find -lasound”
19:43:17 **** Build of configuration Debug for project audio_hello ****
make all
Building file: ../audio_main.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -O0 -march=armv7-a -fno-tree-vectorize -mthumb-interwork -mfloat-abi=hard -mtune=cortex-a9 -Wno-poison-system-directories -I/usr/include -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"audio_main.d" -MT"audio_main.o" -o "audio_main.o" "../audio_main.c"
Finished building: ../audio_main.c
Building target: audio_hello
Invoking: Cross GCC Linker
arm-linux-gnueabihf-gcc -L/srv/nfs/rootfs/usr/lib -Wl,-rpath-link,/srv/nfs/rootfs/usr/lib -lasound -o "audio_hello" ./audio_main.o
Finished building target: audio_hello
19:43:17 Build Finished (took 111ms)
Your replies so far hint that you changed your approach of what or how compiler / headers / rootfs is used, so if the above does not help I suggest you describe of how your current setup looks like, and what your current eclipse settings really are and show the console output of a build after you did run a clean project.