Rust编程2026-02-28 01:00

错误:与 `cc` 链接失败:退出代码:1

rustfan
rustfan
作者

我有一个名为 test1.rs 的单文件程序。当我使用 rustc test1.rs 编译它时,我遇到了错误:

错误:使用 `cc` 链接失败:退出代码:1
提示:cc '-m64' '-L' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib' '-o' 'test1' 'test1.o' '-Wl,-force_load,/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a' '-Wl,-dead_strip' '-nodefaultlibs' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib' '-L' '/usr/local/Cellar/rust/1.0.0-alpha/lib/rustlib/x86_64-apple-darwin/lib' '-L' '/Users/alex/Documents/projects/rust/.rust/lib/x86_64-apple-darwin' '-L' '/Users/alex/Documents/projects/rust/lib/x86_64-apple-darwin' '-lSystem' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
提示:ld: 警告:找不到选项 '-L/Users/alex/Documents/projects/rust/.rust/lib/x86_64-apple-darwin'
ld: 警告:找不到选项 '-L/Users/alex/Documents/projects/rust/lib/x86_64-apple-darwin'
ld: 无法为 x86_64 架构打开输出文件进行写入:test1,errno=21
clang: 错误:链接命令失败,退出代码为 1 (使用 -v 查看调用)

错误:由于之前的错误而中止

$ rustc --version
rustc 1.0.0-dev

我查阅了一些相关主题,但都没有解决这个问题。

33

评论 (0)

登录后评论

立即登录

加载评论中...