Hello!
I am rather new to rust and this is my first post here.
I am currently trying to build a rust static library for a tier 3 target that only support >no_std< development.
When I run >rustc --print target-list< on my machine, the target I need is named in the list. When I try to add the target using >rustup target add (target_name)< I receive following Error:
component 'rust_std' for target 'target_name' is unavailable for download for channel 'stable'
At the same time, if I try to build using >Cargo build --release --target=target_name< I get an Error telling me that it >can't find crate for std< and >target might not be installed<
I could imagine just overlooking some basic fix in the documentation and the guides I have read so far, but I can't seem to get it to work. Thanks in advance for the help!
Edit: I could find some information about the !#[no_std] declaration, which I think helps my case. But even when adding !#[no_std] now the compiler says it can't find core, as the target still can't be found. So is there a way to add a target that doesn't support std, but supports core? (At least I hope my target supports core)
Thank you! As far as I can see in the link you provided, adding these two lines in the cargo.toml file:
[unstable]
build-std = ["core"]
should be enough. My cargo.toml file looks like this at the moment:
[package]
name = "rust_lib"
version = "0.1.0"
edition = "2021"
[unstable]
build-std = ["core"]
[dependencies]
[lib]
name = "rust_lib"
crate-type = ["staticlib"]
If I now run: cargo build --release --target = armv8r-none-eabihf
I get the same error as before: error[E0463] can't find crate for 'core'
This happens for the stable as well as nightly cargo
Okay, in my project folder I created a .cargo-Folder in which i created a config.toml file, where I inserted the two lines.
The outcome is still the same as before.
This means you are building for your host platform. Try running cargo build --target=armv8r-none-eabihf to compile for your desired platform. Might be that you have to tell Cargo what linker it needs to use before it works.
To build my final library I use "cargo build --release --target=armv8r-none-eabihf"(line a)
The "rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc"(line b) was used after I first changed to nightly cargo and tried to run line a. Cargo told me that some files are missing and I should run line b to get them. I did and it worked. Now when I build my library with line a it finishes and I receive a *.a-File, which should be what I am looking for