rust-cargo

Could not exec the linker `cc` error when running “cargo build”

笑着哭i 提交于 2019-12-19 15:46:43
问题 I just installed Rust on my Mac and rustc --version --verbose displays rustc 1.0.0-nightly (91bdf23f5 2015-03-09) (built 2015-03-08) binary: rustc commit-hash: 91bdf23f504f79ed59617cde3dfebd3d5e39a476 commit-date: 2015-03-09 build-date: 2015-03-08 host: x86_64-apple-darwin release: 1.0.0-nightly I cloned a couple of repositories (postgres-extension and erlang-rust-nif) and ran cargo build upon both of them. Both reported the error error: could not exec the linker `cc`: No such file or

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

試著忘記壹切 提交于 2019-12-18 08:58:18
问题 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" } But it doesn't work. Is it possible to add dependency to this crate inside the mentat repository? 回答1: From the Cargo documentation: Cargo will fetch the git repository at this location then look for a Cargo.toml for the requested crate anywhere

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

北城以北 提交于 2019-12-18 08:58:15
问题 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" } But it doesn't work. Is it possible to add dependency to this crate inside the mentat repository? 回答1: From the Cargo documentation: Cargo will fetch the git repository at this location then look for a Cargo.toml for the requested crate anywhere

Is it possible to change the log level for an application at compile time?

筅森魡賤 提交于 2019-12-18 05:04:43
问题 Rather than rely on environment variables at runtime, I'd like to compile a debug or release version with non-error log messages stripped out completely. Is it possible to change the log level for an application in the Cargo.toml or via cargo / rustc command line arguments? 回答1: I don't believe that the log crate has exactly the requested functionality built in. There is a way to statically set the logging level. If you compile the log crate with any of these Cargo features, the log level

Is it possible to change the log level for an application at compile time?

橙三吉。 提交于 2019-12-18 05:04:05
问题 Rather than rely on environment variables at runtime, I'd like to compile a debug or release version with non-error log messages stripped out completely. Is it possible to change the log level for an application in the Cargo.toml or via cargo / rustc command line arguments? 回答1: I don't believe that the log crate has exactly the requested functionality built in. There is a way to statically set the logging level. If you compile the log crate with any of these Cargo features, the log level

Does cargo install have an equivalent update command?

≯℡__Kan透↙ 提交于 2019-12-17 22:54:52
问题 I'd like to update a package that I used cargo install to globally install packages, such as rustfmt or racer. I can't find a way to update an installed package without first deleting it (via cargo uninstall ) and then running the install command again. Is there an update command? 回答1: As of Cargo 1.36.0, you can now use the following command(s) on a nightly toolchain instead of using the cargo-update crate to update crates to their latest version: rustup install nightly cargo +nightly

Set specific version of the dependency of a project's dependency in Cargo.toml or Cargo.lock

非 Y 不嫁゛ 提交于 2019-12-17 21:07:23
问题 Let's say my project A depends on library B that depends on library C. Library B sets the dependency version to "*" (any) so cargo will download the latest version of C. How can I instruct cargo to build library B to using a specific version of library C? Currently I'm trying to build iron. The current build is failing, but I can see the last successful build in https://travis-ci.org/iron/iron/builds/45254195, including rust version and cargo package versions. So I downloaded the specific

Is there a list of all cfg features?

杀马特。学长 韩版系。学妹 提交于 2019-12-17 15:36:03
问题 Rust has the ability to check configuration at build time with, e.g., #[cfg(target_os = "linux")] or if cfg!(target_os = "linux") {...} , where target_os is a feature . Is there a list of all (or, at least, commonly used) features that can be checked in Rust? See related question regarding attributes Is there an exhaustive list of standard attributes anywhere?. 回答1: The "Conditional compilation" section of the Reference has a list of configurations that must be defined (as of Rust 1.14) :

Why are Rust executables so huge?

跟風遠走 提交于 2019-12-17 10:12:27
问题 Just having found Rust and having read the first two chapters of the documentation, I find the approach and the way they defined the language particularly interesting. So I decided to get my fingers wet and started out with Hello world... I did so on Windows 7 x64, btw. fn main() { println!("Hello, world!"); } Issuing cargo build and looking at the result in targets\debug I found the resulting .exe being 3MB. After some searching (documentation of cargo command line flags is hard to find...)

How to idiomatically alias a crate in Rust 2018?

末鹿安然 提交于 2019-12-17 09:59:46
问题 I have a crate foo_sys . In Rust 2015 I used extern crate foo_sys as foo for convenience, but in Rust 2018 extern crate isn't needed anymore and I don't want to use it only for aliasing. When dropping extern crate , I get error[E0463]: can't find crate for foo 回答1: This can be achieved with the rename-dependency Cargo feature, available in Rust 1.31. With this feature, it's possible to provide a package attribute to the dependencies: The rename-dependency feature allows you to import a