我在Debian 9.2系统上使用文档中的说明安装了Rust,并试图编译hello-world示例。编译失败,出现以下错误:
$ rustc main.rs --verbose
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "main.main0.rust-cgu.o" "main.main1.rust-cgu.o" "-o" "main" "main.crate.allocator.rust-cgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-fe0b1b991511fcaa.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-3d7b10e850a67e89.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-28484309357fd6f1.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-751808ba756769d5.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-8cb97051d8238386.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-25cc9b024a02d330.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-d42e80cee81b06ce.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-78c21267a2dc15c1.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-0e1b544c94586415.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0c5e3d6c117f8c44.rlib" "/home/frederick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-bd7cc5ada1e908e0.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util"
= note: ld-wrapper: error: attempt to use impure library "/usr/lib/gcc/x86_64-linux-gnu/6/libgcc_s.so"
collect2: error: ld returned 1 exit status
以下是在我的系统上运行uname -a
的输出
Linux localhost 4.9.0-4-amd64#1 SMP Debian 4.9.51-1(2017-09-28)x86_64 GNU/Linux
我在谷歌上尝试了以下搜索,但似乎找不到任何有用的东西:
- rustc AND ld包装器:错误:试图使用不纯库
- rustc AND ld包装器:错误:尝试使用不纯库"/usr/lib/gcc/x86_64-linux-gnu/6/libgcc_s.so">
- rustc AND错误:与
cc
链接失败:退出代码:1
Debian 9.3是最新版本,但这可能比Debian比Ubuntu测试得少。
在Ubuntu Xenial上,安装/编译说明对我来说很好
您似乎遇到了一个没有很好记录的角落案例,其中有两个参考文献是相关的:
https://www.mail-archive.com/guix-commits@gnu.org/msg34510.html
。。。尝试使用不纯库,错误消息
包装器的目的是检查@code{-L}和@code{-L}开关传递给链接器,添加相应的@code{-rpath}参数,然后使用这组新的参数调用实际的链接器。默认情况下,链接器包装器拒绝链接到存储外部的库确保"纯度"。使用工具链进行与当地图书馆的链接。允许对外部库的引用存储需要定义环境变量@代码{GUIX_LD_WRAPPER_ALLOW_IMPURITIES}。
这段代码:
https://lists.gnu.org/archive/html/help-guix/2016-12/msg00040.html
。。。为了将来参考,要破解haskell包,以下是步骤:
导出GUIX_LD_WRAPPER_ALLOW_IMPURITIES=y。。。
如果GUIX甚至与您的情况相关,那么定义它可能会让您在安装过程中走得更远。