Questions tagged [rust-cargo]

Cargo is the official package manager for the Rust programming language.

Cargo is the official package manager for the Rust programming language. Using a manifest, the programmer can provide metadata about a project, including dependencies, which Cargo can automatically download and compile before compiling the project itself.

You can find more information in the cargo book and browse the crates (Rust packages) in crates.io.

2044 questions
15
votes
2 answers

Error: "linker 'cc' not found" when cross compiling a rust project from windows to linux using cargo

I have a basic rust/cargo project with a single main file and some basic dependencies. The cargo build command works fine when the target is not specified (I am using windows so it builds to windows), but when I try to cross compile the program to…
Yaxlat
  • 665
  • 1
  • 10
  • 25
15
votes
3 answers

Compilation error: can't find crate for `core`

I'm using Rust 1.35.0 to try out some Rust examples and I could not get it to compile, as I keep getting the following message: error[E0463]: can't find crate for `core` I ran rustc --explain E0463 and I see the following message: You need to link…
joesan
  • 13,963
  • 27
  • 95
  • 232
15
votes
1 answer

What is the default optimization level of cargo build --release?

The rustc compiler has four optimization levels, just like GCC: opt-level This flag controls the optimization level. 0: no optimization, also turns on cfg(debug_assertions) (the default). 1: basic optimizations. 2: some optimizations. 3: all…
Bence László
  • 494
  • 2
  • 5
  • 14
15
votes
1 answer

Can not compile a simple Rust program on MacOS

Today I decided to learn Rust, however I tried to compile a simple "hello world" program but I get this error: fn main() { println!("Hi"); } error: linking with `cc` failed: exit code: 1 | = note: "cc" "-m64" "-L"…
SSM
  • 379
  • 5
  • 16
15
votes
4 answers

How to recursively test all crates under a directory?

Some projects include multiple crates, which makes it a hassle to run all tests manually in each. Is there a convenient way to recursively run cargo test ?
ideasman42
  • 42,413
  • 44
  • 197
  • 320
14
votes
1 answer

How do I remove unused dependencies in Cargo.toml?

How do I find out the dependencies in Cargo.toml that are unused? How can I remove them automatically?
z11i
  • 951
  • 11
  • 26
14
votes
3 answers

What's the difference between Cargo's build and rustc commands?

I'm new to Rust and I just created a new project via cargo new my_project. I noticed that cargo offers these two command-line options: build: Compile a local package and all of its dependencies rustc: Compile a package and all of its…
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
14
votes
1 answer

Can I include debug information only for my code without packages?

With included debug info, my binary becomes 400 MB about. This happens because Rust includes debug info for all dependencies. Is there any way to include debug info only for my code? [package] name = "app" version = "0.7.1" edition =…
anatol
  • 145
  • 1
  • 4
14
votes
1 answer

Is there a way to directly run the program built by Cargo in gdb or lldb?

Is there a way to run the program built by Cargo immediately in gdb? cargo has lots of functions and can run the program, so it seems plausible. The expected command would be something like cargo debug.
Alex
  • 9,891
  • 11
  • 53
  • 87
14
votes
1 answer

Can I add a dependent crate that is a subdirectory in a git repository?

I want to use an EDN parser but it is inside https://github.com/mozilla/mentat. https://github.com/mozilla/mentat/tree/master/edn has its own Cargo.toml. I tried this: [dependencies] edn = { git = "https://github.com/mozilla/mentat/tree/master/edn"…
Vee Satayamas
  • 438
  • 4
  • 10
14
votes
1 answer

Does rustc / cargo have a -march=native equivalent?

I feel like binary portability isn't really a concern, and so something like -march=native may always be the default behavior. I can't find anything saying one way or the other though.
Josh
  • 2,077
  • 1
  • 17
  • 21
14
votes
1 answer

Downloading Rust crates using a web browser

Is there any way to download Rust dependencies using a web browser? I currently have internet access through my web browser but not through the command prompt (Windows). I know that I can set up a local fileserver and set Cargo to use a mirror, but…
yinnonsanders
  • 1,831
  • 11
  • 28
14
votes
1 answer

How to you get verbose output from ld when using Cargo?

How do you get the ld linker to be verbose when you use Cargo? I've tried several things in .cargo/config, but without luck. What would the right settings be? When using gcc directly, I can just do -Wl,--verbose. [build] rustflags = [ "-C",…
Cameron Taggart
  • 5,771
  • 4
  • 45
  • 70
14
votes
3 answers

How to compile a static musl binary of a Rust project with native dependencies?

I have a project with dependencies on Hyper and Diesel, and because of that, on native libraries OpenSSL and libpq. The project builds on nightly Rust because it uses compiler plugins. My current attempt is to build on a Docker container. I have the…
GolDDranks
  • 3,272
  • 4
  • 22
  • 30
14
votes
1 answer

How to download the documentation of a crate with Cargo?

In Haskell's Cabal, one can download the documentation for a package. Is it possible with Rust's Cargo? I searched on the Internet but found nothing.
Xwtek
  • 1,151
  • 1
  • 9
  • 19