rust-embedded / linux-embedded-hal

Implementation of the `embedded-hal` traits for Linux devices
Apache License 2.0
232 stars 40 forks source link

Get "-bash: ./test: No such file or directory" error on BeagleBone #54

Open psiphi75 opened 3 years ago

psiphi75 commented 3 years ago

When I use the below configuration and cross compile to ARMv7 I get the following error message on the BeagleBone:

debian@beaglebone:~$ ./test 
-bash: ./test: No such file or directory

When I use v0.2.2 of linux-embedded-hal or earlier I do not get this error. If I remove extern crate linux_embedded_hal as hal; from the code I do not get the error.

Any ideas?

The code

src/main.rs

extern crate linux_embedded_hal as hal;

fn main() {
    println!("Hello");
}

.cargo/config

[target.armv7-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-gcc"
rustflags = ["-Clink-args=-Xlinker -rpath=/usr/lib/arm-linux-gnueabihf"]

Cargo.toml

[package]
name = "test"
version = "0.1.0"
edition = "2018"

[dependencies]
linux-embedded-hal = "0.4.0-alpha.0"

To compile I use:

cargo build --target=armv7-unknown-linux-musleabihf --release
caemor commented 3 years ago

Could you please give us the output from readelf --all ./test | grep interpreter (from https://stackoverflow.com/questions/35071872/bash-no-such-file-or-directory). It looks like there is a problem with your linker :thinking:

psiphi75 commented 3 years ago

Yes, that's it thank you. But only the first part of my problem. The command readelf --all ./test | grep interpreter gave:

      [Requesting program interpreter: /usr/lib/ld.so.1]

So I changed my target to armv7-unknown-linux-gnuabihf and this resulted in:

      [Requesting program interpreter: /lib/ld-linux-armhf.so.3]

Now I'm stuck with the following message on my BeagleBone:

./test: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.32' not found (required by ./test)

I'm going remain with version 0.2.2 for now. Thanks.

ryankurte commented 2 years ago

in your initial .cargo/config it appears you're trying to build a rust musl target using a gnu linker, you need to use one or the other which should look like:

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

[target.armv7-unknown-linux-musleabihf]
linker = "arm-linux-musleabihf-gcc"

to get the musl cross tooling you can either compile it yourself, find a pre-compiled package, or use cross which provides docker containers with the required tooling pre-installed.

./test: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.32' not found (required by ./test)

gnu targets require libc for dynamic linking at runtime, it looks like you don't have this installed on your beaglebone?