错误:与"cc"链接失败:退出代码:1 [英] error: linking with `cc` failed: exit code: 1
问题描述
我有一个单个 .rs文件.当我通过 rustc test1.rs
对其进行编译时,出现错误:
I have a single .rs file. When I compile it by rustc test1.rs
, I get an error:
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
我已经看到了与此主题相关的一些主题,但是没有一个主题可以帮助我解决问题.
I've seen some topic related to this one but none of them helped me to solve the problem.
推荐答案
从您的命令 rustc test1.rs
中,编译器推断可执行文件的名称应为 test1
.链接器尝试打开此文件,以便它可以编写可执行文件,但失败,并以 errno = 21
为其字符串化版本为是目录".
From your command rustc test1.rs
the compiler infers the name of the executable should be test1
. The linker tries to open this file so it can write the executable but fails with errno=21
whose stringified version is "Is a directory".
这建议您在工作目录中有一个名为 test1
的目录,这会导致冲突.
This suggests you have a directory in your working directory called test1
which is causing a conflict.
这篇关于错误:与"cc"链接失败:退出代码:1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!