我正在尝试交叉编译一个简单的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"
动态链接到asound库。如何告诉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
?
答案 0 :(得分:0)
apt-get install libasound-dev:armhf -y
alsa
依赖项:[dependencies]
alsa = { version = "0.2.1", optional = true }
wavy = { path = "./wavy" }
alsa-backend
标志:[features]
alsa-backend = ["alsa"]
--features "alsa-backend"
传递到cargo build --target arm-unknown-linux-gnueabihf
(应应用目标)