简体   繁体   English

使用 rustc 但不使用货物时缺少板条箱

[英]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.

相关问题 在Cargo项目中使用板条箱时出现错误,提示“也许缺少外部板条箱” - Using a crate in a Cargo project errors with “maybe a missing extern crate” 如何仅使用 cargo 或 rustc 为自定义目标编译 Rust 核心板条箱? - How can I compile the Rust core crate for a custom target using only cargo or rustc? 在Xcode中使用NSTask在AppKit应用程序中运行时,Rust 1.4.0(或更高版本)货物/铁锈崩溃 - Rust 1.4.0 (or later) cargo/rustc crashes when run in an AppKit app using NSTask in Xcode 当rustc启用musc时,未能使用货物建立rust-libc - failure to build rust-libc using cargo when rustc is musl-enabled 如何使用 cargo 更新板条箱注册表(索引) - how to update crate registry (index) using cargo 为什么此Rust 2018代码使用`cargo build`编译但不使用rustc编译? - Why does this Rust 2018 code compile with `cargo build` but not using rustc? 如何仅使用rustc而不使用商品链接动态Rust库? - How to link a dynamic Rust library using only rustc and not cargo? 当我使用 rustc 编译时,为什么会出现在 Cargo.toml 中列为依赖项的“找不到板条箱”? - Why do I get "can't find crate" that is listed as a dependency in Cargo.toml when I compile with rustc? 如何使用cargo crate列出项目的源文件? - How to list a project's source files using the cargo crate? 如何使用 cargo 找到最新的稳定版本的 crate? - How can I find the latest stable version of a crate using cargo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM