rust-cargo

I Can't Get Cross Compiling From Ubuntu To Windows Working

為{幸葍}努か 提交于 2020-08-25 07:27:21
问题 I Want To Cross Compile Some Rust Code from Ubuntu to Windows, and receive an error about onexitbegin. Tried to follow various suggestions, but they don't have my specific error message: crt2.o:crtexe.c: (.rdata$.refptr.__onexitend[.refptr.__onexitend]+0x0): undefined reference to `__onexitend' collect2: error: ld returned 1 exit status cargo build --release --target x86_64-pc-windows-gnu Expected to get something built, but it blows up. The output says this: /usr/bin/x86_64-w64-mingw32-ld:

I Can't Get Cross Compiling From Ubuntu To Windows Working

北城余情 提交于 2020-08-25 07:27:08
问题 I Want To Cross Compile Some Rust Code from Ubuntu to Windows, and receive an error about onexitbegin. Tried to follow various suggestions, but they don't have my specific error message: crt2.o:crtexe.c: (.rdata$.refptr.__onexitend[.refptr.__onexitend]+0x0): undefined reference to `__onexitend' collect2: error: ld returned 1 exit status cargo build --release --target x86_64-pc-windows-gnu Expected to get something built, but it blows up. The output says this: /usr/bin/x86_64-w64-mingw32-ld:

How to move tests into a separate file for binaries in Rust's Cargo?

家住魔仙堡 提交于 2020-08-21 09:52:15
问题 I created a new binary using Cargo: cargo new my_binary --bin A function in my_binary/src/main.rs can be used for a test: fn function_from_main() { println!("Test OK"); } #[test] fn my_test() { function_from_main(); } And cargo test -- --nocapture runs the test as expected. What's the most straightforward way to move this test into a separate file, (keeping function_from_main in my_binary/src/main.rs )? I tried to do this but am not sure how to make my_test call function_from_main from a

How to move tests into a separate file for binaries in Rust's Cargo?

*爱你&永不变心* 提交于 2020-08-21 09:47:52
问题 I created a new binary using Cargo: cargo new my_binary --bin A function in my_binary/src/main.rs can be used for a test: fn function_from_main() { println!("Test OK"); } #[test] fn my_test() { function_from_main(); } And cargo test -- --nocapture runs the test as expected. What's the most straightforward way to move this test into a separate file, (keeping function_from_main in my_binary/src/main.rs )? I tried to do this but am not sure how to make my_test call function_from_main from a

How to add external packages and run in rust compiler?

跟風遠走 提交于 2020-08-19 16:55:25
问题 I am compiling and building an example program using rust. I chose rustc instead of cargo for compiling because it being a simple personal test project. So far using rustc for compiling and building executable worked fine but when I tried to add an external rand package its giving me this error 1 | extern crate rand; | ^^^^^^^^^^^^^^^^^^ can't find crate This is the full code extern crate rand; use rand::Rng; fn main() { for x in 1..11 { let random_number = rand::thread_rng() .gen_range(1,

How to add external packages and run in rust compiler?

你。 提交于 2020-08-19 16:52:35
问题 I am compiling and building an example program using rust. I chose rustc instead of cargo for compiling because it being a simple personal test project. So far using rustc for compiling and building executable worked fine but when I tried to add an external rand package its giving me this error 1 | extern crate rand; | ^^^^^^^^^^^^^^^^^^ can't find crate This is the full code extern crate rand; use rand::Rng; fn main() { for x in 1..11 { let random_number = rand::thread_rng() .gen_range(1,

Unable to find crate that is listed in [build-dependencies] section

倖福魔咒の 提交于 2020-08-04 21:52:04
问题 I try to compile my project with the command cargo build . build.rs extern crate csv; use std::path::Path; use std::fs::OpenOptions; use std::io::BufWriter; use std::io::Write; #[allow(non_snake_case)] fn processCSV(filename: &str, sourcePath: &str, enumName: &str) { println!("Generate rust source code from schema {}",filename); let mut ret: Vec<String> = Vec::new(); let mut rdr = csv::Reader::from_file(filename).unwrap().flexible(true); for record in rdr.records().map(|r| r.unwrap()) { } let

Unable to find crate that is listed in [build-dependencies] section

江枫思渺然 提交于 2020-08-04 21:51:25
问题 I try to compile my project with the command cargo build . build.rs extern crate csv; use std::path::Path; use std::fs::OpenOptions; use std::io::BufWriter; use std::io::Write; #[allow(non_snake_case)] fn processCSV(filename: &str, sourcePath: &str, enumName: &str) { println!("Generate rust source code from schema {}",filename); let mut ret: Vec<String> = Vec::new(); let mut rdr = csv::Reader::from_file(filename).unwrap().flexible(true); for record in rdr.records().map(|r| r.unwrap()) { } let

Unable to find crate that is listed in [build-dependencies] section

时光总嘲笑我的痴心妄想 提交于 2020-08-04 21:49:54
问题 I try to compile my project with the command cargo build . build.rs extern crate csv; use std::path::Path; use std::fs::OpenOptions; use std::io::BufWriter; use std::io::Write; #[allow(non_snake_case)] fn processCSV(filename: &str, sourcePath: &str, enumName: &str) { println!("Generate rust source code from schema {}",filename); let mut ret: Vec<String> = Vec::new(); let mut rdr = csv::Reader::from_file(filename).unwrap().flexible(true); for record in rdr.records().map(|r| r.unwrap()) { } let