Can't find crate for `std` when building on a raspberry pi

I'd like to use rust for a program being written on a raspberry pi that uses an ssd1306 oled display and found the ssd1306 crate and an example that runs on the raspberry pi and after some fiddling around it works but not perfectly and the crates used are older versions. I then found a newer example at that uses the latest crates and seems to generally be "better" but I can't get the example to build actually on a raspberry pi which is my preferred place to build as although I have the relevant toolschains installed I keep getting a>

pi@raspberrypi:~/ssd1306/examples/raspi $ cargo run
Compiling void v1.0.2
error[E0463]: can't find crate for std
= note: the thumbv7m-none-eabi target may not be installed

error: aborting due to previous error

For more information about this error, try rustc --explain E0463.
error: could not compile void.


although the right toolchain is installed

thumbv7em-none-eabihf (installed)
thumbv7m-none-eabi (installed)

i'm very much a rust newbie although i know the basics and this is driving me nuts

can anyone help or give me pointers on how to fix this so the example will build/run and then I can get back to work trying to port my program to rust which i'm doing to try to learn rust "properly"


thumbv7m-none-eabi is for bare metal targets. It only has libcore and I think liballoc. It doesn't have libstd. The correct triple is armv7-unknown-linux-gnueabi for the soft-float and armv7-unknown-linux-gnueabihf for the hard-float abi. (I am not quite sure which one is used by raspbian)

I actually started with the defaults that rustup installed and got the same error, exactly the same which is why I then installed the thumbv7m-none-eabi as that's what the error message said it needed.

pi@raspberrypi:~/ssd1306/examples/raspi $ rustup show
Default host: arm-unknown-linux-gnueabihf
rustup home: /home/pi/.rustup

installed targets for active toolchain


active toolchain

stable-arm-unknown-linux-gnueabihf (default)
rustc 1.46.0 (04488afe3 2020-08-24)

pi@raspberrypi:~/ssd1306/examples/raspi $

Try building and running for the ARM Linux target:

cargo run --target arm-unknown-linux-gnueabihf

(This should be the default behavior; I'm not sure why it is defaulting to thumbv7-none-eabi.)

after the previous reply I decided to try just that and so far (it's slow as this is a Pi2) it seems to be working. (fingers crossed and touch wood)

if this is the solution i'm going to slap myself as i'd been trying everything from messing around with the Cargo.toml to reinstalling rust :slight_smile:


thank you both. that WAS the solution and I feel a right wazzock now as i'd been struggling on this for 3 days as I just assumed that the target would be correct as it was the only toolchain originally installed and cargo/rustc would know that.

well we all know what assume means :slight_smile:

Can you create a ticket against the rustup repository?

Ideally a cargo build should just work out of the box regardless of the platform, you shouldn't have needed to mess about with targets. The fact that it happened again after reinstalling may indicate a bug instead of user error.

If you haven't done so already, you can set the default target with rustup default stable-arm-unknown-linux-gnueabihf.


1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.