Und*_*der 3 linker-errors rust rlib
我正在按照本教程学习如何在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"]
Run Code Online (Sandbox Code Playgroud)
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{}}
Run Code Online (Sandbox Code Playgroud)
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"
}
Run Code Online (Sandbox Code Playgroud)
这是Makefile.
如果向下滚动到教程中的Fixing Linker Errors部分,我们基本上要求我们添加以下行Cargo.toml:
[dependencies]
rlibc = "1.0"
Run Code Online (Sandbox Code Playgroud)
然后在lib.rs(之后#![no_std])指定外部包:
extern crate rlibc;
Run Code Online (Sandbox Code Playgroud)
当我make run在终端中运行时,收到以下错误消息:
error: Error loading specification: Could not find specification for target "x86_64-blog_os"
error: Could not compile 'rlibc'
Run Code Online (Sandbox Code Playgroud)
我们预计会出现错误...而不是这个错误." 修复链接器错误"部分中的示例提供了我们应该期望的错误类型的概念.
可能出现什么问题?我在谷歌的任何地方搜索都没有解决方案.
小智 6
我有同样的问题.Xargo和Cargo上的这些问题似乎表明目标规范的位置有一个错误:
RUST_TARGET_PATH=pwd在调用之前设置xargo为我修复了问题.给定Makefile中的调用将如下所示:
@RUST_TARGET_PATH=$(shell pwd) xargo build --target $(target)
Run Code Online (Sandbox Code Playgroud)