Today I experiment with building a simple "hello world" binary using two crates.
The main crate has a single source file main.rs, which is listed as follows:
extern crate pr;
fn main() {
pr::pr();
}
The main crate calls the "pr" crate, which is a library crate. The pr crate also has a single source file lib.rs:
pub fn pr() {
println!("Hello, world!");
}
The two crates live in their respective directories. Now I use cargo to build pr. It is successful.
In cargo.toml of the main crate, there is the following segment:
[dependencies]
pr = "0.1.0"
Therefore I have declared the fact that main crate uses the pr crate both in the source file and in the cargo.toml. But when I use cargo to build the binary, I see the following error message:
Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): unknown certificate check f
ailure; class=Net (12); code=Certificate (-17)
warning: spurious network error (1 tries remaining): unknown certificate check f
ailure; class=Net (12); code=Certificate (-17)
error: failed to load source for a dependency onpr
Caused by:
Unable to update registryhttps://github.com/rust-lang/crates.io-index
Caused by:
failed to fetchhttps://github.com/rust-lang/crates.io-index
Caused by:
unknown certificate check failure; class=Net (12); code=Certificate (-17)
So it seems that cargo only supports using crates published in crates.io?
If I don't want to publish pr in crates.io, then how can we build the binary?
If this can be done directly using rustc but not cargo, then how to write the command line? Furthemore, if pr is a closed-source crate, i.e. I only have pr.rlib, but not the rs file, then how can I use pr?