rust - `xargo build` 找不到库

标签 rust rust-cargo

所以我正在关注 this tutorial关于如何使用 Rust 编程语言创建非常基本的操作系统。 (我打算购买一本关于该主题的实际书籍,但我现在正在使用它)。

这里是我们创建的一些文件,只是为了澄清一些事情:

Cargo.toml

[package]
name = "blog_os"
version = "0.1.0"
authors = ["Philipp Oppermann <dev@phil-opp.com>"]   # Here I used my own details

[lib]
crate-type = ["staticlib"]

src/lib.rs

#![feature(lang_items)]
#![no_std]

#[no_mangle]
pub extern fn rust_main() {}

#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}}

x86_64-blog_os.json

{
  "llvm-target": "x86_64-unknown-none",
  "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
  "linker-flavor": "gcc",
  "target-endian": "little",
  "target-pointer-width": "64",
  "target-c-int-width": "32",
  "arch": "x86_64",
  "os": "none",
  "disable-redzone": true,
  "features": "-mmx,-sse,+soft-float"
}

如果您向下滚动到教程中的编译部分,作者向我们展示了如何安装xargo 以及如何使用它来构建.

然后我们被要求运行:

> xargo build --target=x86_64-blog_os

但是当我这样做时,我收到以下错误消息:

error: failed to parse manifest at '/home/max/TesterOS/src/Cargo.toml'

Caused by:
  can't find library 'blog_os', rename file to 'src/lib.rs' or specify lib.path

问题是否与我保存文件的位置有关?因为我严格按照教程进行操作,但作者并未具体说明所有内容应保存在何处。

最佳答案

已解决:事实证明它实际上与我放置文件的位置有关。

我必须创建一个 blog_os 文件夹并将我的文件存储在其中。因此错误:

can't find library 'blog_os'....

菜鸟错误:)

关于rust - `xargo build` 找不到库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48035724/

相关文章:

rust - Rust中的每个泛型是否都必须实现某些特征才能拥有 'methods'?

rust - 多个可执行文件使用私有(private)模块的正确位置

rust - 如何处理 Rust/Cargo 中的 3rd 方静态 C 库依赖项?

multithreading - 在多个线程中超出范围运行函数

rust - 为什么这会变成堆栈溢出?

multithreading - rust "future cannot be sent between threads safely"

git - 我可以在 git 存储库中添加一个作为子目录的依赖包吗?

rust - 为什么 cargo 项目失败了?

node.js - 如何链接到本地​​ Rust 库? (类似于 npm 链接)

rust - 无法安装 cargo wasm-pack