rust-cargo

Does Rust libc crate inhibit the compilation of custom panic handler?

旧街凉风 提交于 2019-12-11 09:55:12
问题 So we are currently trying to compile some Rust code that we can then link to some C code. To do this we are using Bindgen to generate an FFI, and then we will use it to call some C functions from Rust. However, we must first have the crate "libc" as a dependency in the Cargo.toml file of the project. The project we are currently working on demands that we use the crate wide !#[no_std] attribute, as we don't want the entire stdlib of Rust. We only need the core. The libc crate says we can

How to build the docs.rs documentation of an FFI crate when the native library is not present?

旧城冷巷雨未停 提交于 2019-12-11 07:46:17
问题 I have a "sys" crate that links statically to a library: Cargo.toml: [package] links = "foo-1.0" build.rs: fn main() { println!("cargo:rustc-link-lib=dylib=foo-1.0"); } When I publish the package, docs.rs cannot generate the documentation because libfoo is not installed: error: failed to run custom build command for `foo-sys v0.0.1` Caused by: process didn't exit successfully: `/home/cratesfyi/cratesfyi/debug/build/foo-sys-f4bd3ee95677500b/build-script-build` (exit code: 1) --- stderr `"pkg

Cannot call CryptDecrypt from the WinApi crate because it could not find the module

六月ゝ 毕业季﹏ 提交于 2019-12-11 02:53:05
问题 In the documentation it says that the function is in winapi::um::wincrypt::CryptDecrypt but when I install the crate and bring it in my project everything works fine until I try to call the function where I get the following error message: error[E0433]: failed to resolve. Could not find `wincrypt` in `um` --> src\main.rs:68:39 | 68 | let decrypted_password = winapi::um::wincrypt::CryptDecrypt(password); | ^^^^^^^^ Could not find `wincrypt` in `um` My goal is to decrypt passwords from the

How do I statically link the openssl-sys crate into a shared library?

北城余情 提交于 2019-12-10 22:43:58
问题 I am using a library which depends on openssl-sys. According to the documentation, if I specify OPENSSL_STATIC=1 as an environment variable, OpenSSL will be statically linked into the shared library output. Due to a host of complicated problems, I need to statically link OpenSSL into my shared library output. Here is my Cargo.toml : [package] name = "api" version = "0.1.0" authors = ["Naftuli Kay <me@naftuli.wtf>"] publish = false [lib] name = "lambda" crate-type = ["cdylib"] [dependencies]

How to pass -L linker flag to rustc for cargo based project?

北慕城南 提交于 2019-12-10 22:03:30
问题 How do I make cargo pass -L linker flag to rustc invocations? 回答1: Not yet. However, you can use a custom makefile for given Cargo project instead. For example, Servo uses the Skia library by having a Rust wrapper in the same cargo project, and a build key that calls a custom makefile. You can do something similar in this case, for now. 回答2: It is now possible using .cargo/config . See https://github.com/rust-lang/cargo/issues/1109 and http://doc.crates.io/config.html. 来源: https:/

How to build Rust examples without running

旧城冷巷雨未停 提交于 2019-12-10 15:47:42
问题 Is there any way to build Rust examples without running them? Specifically to test examples build successfully using Travis CI. 回答1: cargo test automatically builds examples (but doesn't run them). I believe it does this first, before the main test runners, but you can verify with cargo test -v . 回答2: I use the following code to run with Travis language: rust rust: - stable - beta script: - cargo build --verbose --all - cargo test --verbose --all 回答3: cargo test runs examples. To build them

cargo build of the same code: spurious compile time errors?

丶灬走出姿态 提交于 2019-12-10 15:29:27
问题 I have crate A that depend on B and B depend on rust-nmea crate. If I build crate A I got bunch of errors (all of them that missed use std::error::Error; ) during build of rust-nmea dependency: error[E0599]: no method named `description` found for type `nom::Err<&[u8]>` in the current scope --> /home/evgeniy/.cargo/registry/src/github.com-1ecc6299db9ec823/nmea-0.0.6/src/parse.rs:100:44 | 100 | IError::Error(e) => e.description().to_string(), | ^^^^^^^^^^^ | = help: items from traits can only

What is a suitable place to store procedural macro artifacts so that they are cleaned up by `cargo clean`?

久未见 提交于 2019-12-10 14:54:41
问题 I'm working on a procedural macro that needs a place to store state on the system where it is run. The state should be cleaned up when cargo clean is run. In the past, I've assumed that the target directory is the proper place. However, my assumption is likely incorrect because: my files and directories may conflict with those of rustc and cargo . the location of the target directory can change from the default. In an effort to avoid these issues, I've been attempting to determine a way to

How to get the linker to produce a map file using Cargo

▼魔方 西西 提交于 2019-12-10 14:44:45
问题 I'm writing a Rust program targeted for an STM32F407 processor using zinc. I'd like to be able to produce a linker map file. I've found that I can put the following in my main.rs and this gives me the desired result: #![feature(link_args)] #[link_args = "-Wl,-Map=blink_stm32f4.map"] extern {} However, the documentation for link_args suggests not to use this method. What other methods exist to get the linker to produce a map file? 回答1: link-args is possible to pass to rustc via rustc -C link