[英]Missing crate when using rustc but not using cargo
I'm using the epub crate on version 1.2.3 and my Cargo.toml is formatted as such我在 1.2.3 版上使用 epub crate 并且我的 Cargo.toml 格式是这样的
[package]
name = "cl-epub-reader"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
epub = "1.2.22"
and my main.rs is我的 main.rs 是
use epub::doc::EpubDoc;
use epub::doc::NavPoint;
use std::env::args;
fn main() {
let args: Vec<String> = args().collect();
let doc = EpubDoc::new(&args[1]).unwrap();
// assert!(doc.is_ok());
println!("{:?}", doc.mdata("title"));
}
all it does is get the uses the path from the a user input then it gets the title metadata and printing it.它所做的只是从用户输入中获取使用路径,然后获取标题元数据并打印出来。
when I run cargo run
it outputs an error about an error about going out of range, which is expected however when I run rustc src/main.rs
the error is error[E0433]: failed to resolve: maybe a missing crate `epub`?
当我运行cargo run
它输出一个关于超出范围错误的错误,这是预期的,但是当我运行rustc src/main.rs
,错误是error[E0433]: failed to resolve: maybe a missing crate `epub`?
Does anyone know the cause of this and how to solve this issue?有谁知道这个问题的原因以及如何解决这个问题? Thanks in advanced :)提前致谢 :)
When you call rustc
directly, you need to pass the appropriate options to tell the compiler where the crates are installed on you computer.当您直接调用rustc
,您需要传递适当的选项来告诉编译器在您的计算机上安装 crate 的位置。 cargo
handles that automatically for you (you can use the -v
option to cargo build
to see the actual rustc
command lines it uses). cargo
会自动为你处理(你可以使用-v
选项来进行cargo build
来查看它使用的实际rustc
命令行)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.