2016-09-19 91 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'參數添加正確的路徑。你有什麼目標根文件系統? –