【发布时间】:2019-11-24 00:38:33
【问题描述】:
我正在尝试交叉编译一个简单的 Rust 程序,以便在安装了 libasound-dev 库的 Docker 容器内使用 wavy crate 在 Raspberry Pi Zero 上使用 ALSA 驱动程序录制声音。但是,链接器抱怨:
note: /opt/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lasound
collect2: error: ld returned 1 exit status
Cargo 似乎要求 rustc 使用参数 -Bdynamic" "-lasound" 动态链接到健全的库。我如何告诉 Cargo 在哪里可以找到这些 ALSA 库?
更新:我将以下内容添加到我的 Cargo.toml 文件中,并将 --features "alsa-backend" 添加到我的 cargo build 命令中,这似乎已经推进了构建:
[features]
alsa-backend = ["alsa"]
[dependencies]
alsa = { version = "0.2.1", optional = true }
现在抛出:
note: /usr/lib/x86_64-linux-gnu/libasound.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
好的,所以它链接到 x86_64 版本的 libasound.so。我在我的 Docker 容器中输入了 dpkg -L libasound-dev,实际上,它列出了 /usr/lib/x86_64-linux-gnu/libasound.so 而不是 ARM 版本。
如何让 Raspbian Docker 容器链接到 ARM 版本的 libasound.so?
【问题讨论】:
标签: docker rust arm raspbian alsa