Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo build fails: can't find crate for std #58

Closed
wucke13 opened this issue Nov 12, 2018 · 9 comments
Closed

cargo build fails: can't find crate for std #58

wucke13 opened this issue Nov 12, 2018 · 9 comments

Comments

@wucke13
Copy link

wucke13 commented Nov 12, 2018

The output of the error is the following:

   Compiling rust-toolchain v0.1.0 (/tmp/test)                                                                                                                                       
     Running `rustc --crate-name rust_toolchain src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=f8ada62e29834902 -C extra-filename=-f8ada62e29834902 --out-dir /tmp/test/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -C incremental=/tmp/test/target/thumbv7em-none-eabihf/debug/incremental -L dependency=/tmp/test/target/thumbv7em-none-eabihf/debug/deps -L dependency=/tmp/test/target/debug/deps --extern stm32f3=/tmp/test/target/thumbv7em-none-eabihf/debug/deps/libstm32f3-89c96bc170109bc0.rlib -C link-arg=-Tlink.x -L /tmp/test/target/thumbv7em-none-eabihf/debug/build/stm32f3-7c665be50e2d2105/out -L '/home/wucke13/documents/people/Günther Kemnitz/rust-toolchain/target/thumbv7em-none-eabihf/debug/build/cortex-m-e093635255097b24/out' -L /tmp/test/target/thumbv7em-none-eabihf/debug/build/cortex-m-rt-28a646978498040b/out`
error[E0463]: can't find crate for `std`                                                                                                                                             
  |                                                                                                                                                                                  
  = note: the `thumbv7em-none-eabihf` 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 `rust-toolchain`.                                                                                                                                           

Caused by:
  process didn't exit successfully: `rustc --crate-name rust_toolchain src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=f8ada62e29834902 -C extra-filename=-f8ada62e29834902 --out-dir /tmp/test/target/thumbv7em-none-eabihf/debug/deps --target thumbv7em-none-eabihf -C incremental=/tmp/test/target/thumbv7em-none-eabihf/debug/incremental -L dependency=/tmp/test/target/thumbv7em-none-eabihf/debug/deps -L dependency=/tmp/test/target/debug/deps --extern stm32f3=/tmp/test/target/thumbv7em-none-eabihf/debug/deps/libstm32f3-89c96bc170109bc0.rlib -C link-arg=-Tlink.x -L /tmp/test/target/thumbv7em-none-eabihf/debug/build/stm32f3-7c665be50e2d2105/out -L '/home/wucke13/documents/people/Günther Kemnitz/rust-toolchain/target/thumbv7em-none-eabihf/debug/build/cortex-m-e093635255097b24/out' -L /tmp/test/target/thumbv7em-none-eabihf/debug/build/cortex-m-rt-28a646978498040b/out` (exit code: 1)

rustup show shows that the needed target is installed, though:

Default host: x86_64-unknown-linux-gnu

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
beta-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

installed targets for active toolchain
--------------------------------------

thumbv6m-none-eabi
thumbv7em-none-eabi
thumbv7em-none-eabihf
thumbv7m-none-eabi
x86_64-unknown-linux-gnu

active toolchain
----------------

beta-x86_64-unknown-linux-gnu (default)
rustc 1.31.0-beta.8 (9142ac95a 2018-11-10)

What causes this?

@japaric
Copy link
Member

japaric commented Dec 1, 2018

error[E0463]: can't find crate for std

Likely src/main.rs does not have the #![no_std] attribute in it.

@wucke13
Copy link
Author

wucke13 commented Dec 24, 2018

Thats it! Thanks!

@wucke13 wucke13 closed this as completed Dec 24, 2018
@H-Y-B
Copy link

H-Y-B commented Apr 20, 2019

error[E0463]: can't find crate for std

Likely src/main.rs does not have the #![no_std] attribute in it.

But if i want to print "Hello world" by using std::println! , what should I do?

@georgio
Copy link

georgio commented Jun 7, 2019

@H-Y-B This might answer your question :-)
https://docs.rust-embedded.org/discovery/06-hello-world/index.html

@0xAl3xH
Copy link

0xAl3xH commented Oct 17, 2019

What if one needs to use other std libraries like std::ptr for example?

@adamgreig
Copy link
Member

What if one needs to use other std libraries like std::ptr for example?

Everything you can use in a #[no_std] context is in core, for example: core::ptr. Many std modules are re-exported from core.

@niondir
Copy link

niondir commented Apr 12, 2020

Is there a way to find out where std is used? I have the #![no_std] in my main.

@wucke13
Copy link
Author

wucke13 commented Apr 12, 2020

@niondir Isn't it already stated in the cargo output? Other than that, just grep for std:: in your src. Do you have any deps through Cargo.toml? Some deps have no_std as a feature, which needs to be invoked explicitly for them to be no_std conform.

@niondir
Copy link

niondir commented Apr 12, 2020

I actually found another file where the #![no_std] was missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants