gpt4 book ai didi

ld - 带有 Rust 的可移植二进制文件

转载 作者:行者123 更新时间:2023-11-29 07:44:50 27 4
gpt4 key购买 nike

我在使用 rust 构建可移植可执行文件时遇到问题。

在 Ubuntu 上运行使用 cargo build 构建的可执行文件失败

./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./test)

使用 rustc ... -C link-args=-static 构建无法正确链接(ld ./test 的输出):

ld: error in ./test(.eh_frame); no .eh_frame_hdr table will be created.

除了在具有旧 glibc 版本的旧系统上构建之外,是否有解决此问题的方法?

最佳答案

Glibc 不是静态链接的(正如我们可能希望的那样,它竭尽全力防止这种情况发生)。因此,系统库(libstd 等)始终依赖于构建它们的 glibc 版本。这就是为什么 mozilla 使用的 linux 集群中的 buildbots 是旧版本的 centos。

参见 https://github.com/rust-lang/rust/issues/9545https://github.com/rust-lang/rust/issues/7283

不幸的是,目前我认为除了确保您在 glibc 比您要部署到的系统更旧的系统上构建之外,没有其他解决方法。

关于ld - 带有 Rust 的可移植二进制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26202494/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com