我有single.rs文件.当我以rustc test1.rs编译它时,我得到一个错误:

    error: linking with `cc` failed: exit code: 1
note: 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'
note: ld: warning: directory not found for option '-L/Users/alex/Documents/projects/rust/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/alex/Documents/projects/rust/lib/x86_64-apple-darwin'
ld: can't open output file for writing: test1, errno=21 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error


$ rustc --version
rustc 1.0.0-dev

我看过一些与此相关的话题,但没有一个能帮我解决这个问题.

推荐答案

根据命令rustc test1.rs,编译器推断出可执行文件的名称应该是test1.链接器试图打开此文件,以便可以写入可执行文件,但由于errno=21的字符串化版本为"is a directory",链接器失败.

这表明您的工作目录中有一个名为test1的目录,这导致了冲突.

Rust相关问答推荐

SQL x中的mut *transaction和mut transaction有什么区别?

在Tauri中获取ICoreWebView 2_7以打印PDF

如何从Rust记录WASM堆内存使用情况?

如何处理动态 struct 实例化?

这是不是在不造成嵌套的情况下从枚举中取出想要的变体的惯用方法?

如何计算迭代器适配器链中过滤的元素的数量

有没有一种惯用的方法来判断VEC中是否存在变体?

为什么铁 rust S的默认排序功能比我对小数组的 Select 排序稍微慢一些?

从未排序的链表中删除重复项的铁 rust 代码在ELSE分支的低级上做了什么?

Rust,如何从 Rc> 复制内部值并返回它?

当我try 使用 SKI 演算中的S I I实现递归时,为什么 Rust 会失败?

需要一个有序向量来进行 struct 初始化

为什么 Rust 字符串没有短字符串优化 (SSO)?

从 Rust 中的 if/else 中的引用创建 MappedRwLockWriteGuard

在 Rust 中实现资源消耗的安全包装器

从 HashMap>, _> 中删除的生命周期问题

错误:将自定义 proc_macro 与用Rust 的宝贝编写的属性一起使用时,无法在此范围内找到属性

为什么我可以同时传递可变和不可变引用?

Rust,使用枚举从 HashMap 获取值

为什么 match 语句对引用类型比函数参数更挑剔?