Docker 交叉编译ARM的Rust程序时的ALSA链接
我正在尝试交叉编译一个简单的Rust程序,使用安装了Docker 交叉编译ARM的Rust程序时的ALSA链接,docker,rust,arm,raspbian,alsa,Docker,Rust,Arm,Raspbian,Alsa,我正在尝试交叉编译一个简单的Rust程序,使用安装了libasound dev库的Docker容器内部的,在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 -las
libasound dev
库的Docker容器内部的,在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文件中,并将--功能“alsa后端”
添加到我的货物构建
命令中,该命令似乎已经推进了构建:
[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
好的,它链接到了libasound.so的x86_64版本。我在Docker容器中键入了dpkg-L libasound dev
,实际上,它列出了/usr/lib/x86_64-linux-gnu/libasound.so
,而不是ARM版本
如何让Raspbian Docker容器链接到ARM版本的libasound.so
?解决方案:
libasound dev:armhf
,它会抱怨alsa sys
链接器错误。)
alsa
依赖项添加到Cargo.toml:flag:
.cargo/config
中使用armhf版本:(根据链接的顺序,它可能会尝试使用x86版本而不是armhf版本。)感谢您分享解决方案!
apt-get install libasound-dev -y
apt-get install libasound-dev:armhf -y
[dependencies]
alsa = { version = "0.2.1", optional = true }
wavy = { path = "./wavy" }
[features]
alsa-backend = ["alsa"]
[build]
[target.arm-unknown-linux-gnueabihf.libasound]
linker = "arm-linux-gnueabihf-gcc"
rustc-link-lib = ["libasound"]
rustc-link-search = ["/usr/lib/arm-linux-gnueabihf"]