【问题标题】:ALSA Library and Cross Compiling for ARMALSA 库和 ARM 交叉编译
【发布时间】:2017-01-26 18:11:51
【问题描述】:

我正在尝试为我的 NXP(Freescale) imx6 制作一个安装了 Debian OS 的“C”应用程序。我的主机是 Ubuntu 16.04。我使用 eclipse 作为 IDE,直到今天我都可以进行交叉编译。我使用arm-linux-gnueabihf-gcc 作为编译器,使用arm-linux-gnueabihf-ld 作为链接器。我在链接器参数中添加了-lasound 选项,但仍然无法构建应用程序。我收到一个错误

arm-linux-gnueabihf-ld: 找不到 -lasound

我认为我的 Ubuntu(主机)机器上没有 libasound.so 文件,并且我的链接器无法将库链接到我的应用程序。

我将libasound.so 文件从我的ARM 机器复制到我的主机到/home/user/Downloads 文件夹,但仍然无法编译。

在构建之前是否有在交叉编译项目中使用 ALSA 库的步骤?

这是构建操作的输出

Building target: tihc_linux_application
Invoking: GCC C Linker
/usr/bin/arm-linux-gnueabihf-ld -static -L/home/user/Downloads -pthread -lasound -o "main"  ./src/main.o   
/usr/bin/arm-linux-gnueabihf-ld: mode armelf_linux_eabi
/usr/bin/arm-linux-gnueabihf-ld: cannot find -lasound

【问题讨论】:

    标签: c linux gcc alsa


    【解决方案1】:

    您要求静态链接(通过-static)但提供共享库,因此ld 可能会忽略它(以确保您可以使用-Wl,--verbose 运行)。一种选择是从头开始交叉编译 libalsa,然后使用生成的静态库链接您的应用程序。另一种选择是在某处搜索预编译的 gnueabihf libalsa...

    【讨论】:

    • 我删除了静态标志并添加了详细标志。在这些更改之后,正如您所提到的,链接器找到了共享对象文件,但这次我又遇到了另一个错误。 //usr/arm-linux-gnueabihf/lib/libc.so.6: error adding symbols: DSO missing from command line
    • @BlackGlix 那是strange-linking-error-dso-missing-from-command-line。 TLDR - 将目标文件移动到命令行的前面,将库移动到末尾。
    猜你喜欢
    • 2016-07-11
    • 2019-11-24
    • 1970-01-01
    • 1970-01-01
    • 2014-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多