简体   繁体   中英

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

[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

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`? 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. cargo handles that automatically for you (you can use the -v option to cargo build to see the actual rustc command lines it uses).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM