2016-09-19 141 views
0

我正在尝试为基于linux-arm的处理器交叉编译ALSA Lib应用程序。我正在使用eclipse为我做这个构建。应用程序的构建阶段是成功的,但是当gcc链接器尝试完成时我会发生错误。ALSA Lib 1.1.2编译错误

我收到以下错误

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 to snd_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 to snd_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 to snd_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 to snd_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 to snd_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 to snd_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 to snd_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 to snd_pcm_hw_params' /home/neonws/sound/Debug/../play.c:57: undefined reference to snd_strerror' /home/neonws/sound/Debug/../play.c:62: undefined reference to snd_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 to snd_strerror' /home/neonws/sound/Debug/../play.c:71: undefined reference to snd_pcm_writei' /home/neonws/sound/Debug/../play.c:72: undefined reference to snd_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秒完成建造(带75ms)

我使用从ASLA-LIB API的Sample Playback Program

我想知道是什么导致链接器失败?

回答

0

您错过了asound库链接,请将-lasound添加到您的链接标志(请参阅this question,它告诉Eclipse中适当的位置)。并可能删除-L/proc/asound,我不认为你有你的图书馆。

+0

>构建目标:声音 调用:交叉GCC链接器 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 -sound /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:无法找到-sound makefile:29:目标'声音'的配方失败 collect2:错误:ld返回1退出状态 make:*** [sound]错误1 14:18:14构建完成(花费76ms) – JavaProgrammer

+0

Hi @Roman 我按照你的建议,它给了我一个链接器错误,说“-sound not found” 你可以请建议一个解决方案。 我在库(-l)中添加了“asound”,后面跟着链接器库搜索路径(-L)中的路径。 – JavaProgrammer

+0

@JavaProgrammer:很难分辨你的库在哪里,现在你在库搜索路径中缺少库,你应该用'-L'参数添加正确的路径。你有什么目标根文件系统? –