• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

交叉编译后缺少共享库的替代解决方案?

用户头像
it1352
帮助1

问题说明

我首先交叉编译Rust项目到linux target

I first cross compile my Rust project to linux target

cargo build --target x86_64-unknown-linux-gnu

然后在本地ubuntu上运行 ldd ,并且链接器工作正常.

Then run ldd on my local ubuntu and the linker works fine.

linux-vdso.so.1 (0x00007fffddc62000)
libssl.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007f6d34500000)
libcrypto.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007f6d340b0000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6d33ea0000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6d33c90000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6d33a70000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6d33850000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6d33440000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6d35a00000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6d330a0000)

但是在我的目标操作系统上, ldd 无法找到库

But on my target os, ldd fails to find the libraries

libssl.so.1.0.0 => not found
libcrypto.so.1.0.0 => not found
/lib64/libc.so.6 => version `GLIBC_2.18' not found

实际上,我在 LD_LIBRARY_PATH 下安装了 libssl.so.10 libcrypto.so.10 .不幸的是,我无法安装Rust所需的版本为 1.0.0 的共享库.

Actually I have libssl.so.10 and libcrypto.so.10 installed under LD_LIBRARY_PATH. Unfortunately I am not able to install shared libraries of version 1.0.0 required by Rust.

我已阅读 Rust Cross ,建议的解决方案是安装缺少的共享库.不幸的是,这对我来说是不可能的.因此,我正在寻找丢失的库的替代解决方案.

I have read Rust Cross and the recommended solution is to install the missing shared libraries. Unfortunately that's not possible for me. So I am looking for alternative solutions to missing libraries.

libssl.so.1.0.0 libcrypto.so.1.0.0 听起来很古老.如何告知 cargo 使用更高版本?

libssl.so.1.0.0 and libcrypto.so.1.0.0 sound ancient. How can I tell cargo to use a later version?

我该如何处理/lib64/libc.so.6 =>找不到版本GLIBC_2.18 ?

正确答案

#1

根据 GLIBC_2.18 无法安装到 RHEL7 .我放弃了动态链接的库.

According to this, GLIBC_2.18 can't be installed to RHEL7. I gave up dynamically linked libraries.

帖子帮助了我.解决方案是:

This post helped me out. The solution is:

[dependencies]
nats = "*"
protobuf = { version = "~2.0" }
# Add openssl-sys as a direct dependency so it can be cross compiled to
# x86_64-unknown-linux-musl using the "vendored" feature below
openssl-sys = "*"

[features]
# Force openssl-sys to staticly link in the openssl library. Necessary when
# cross compiling to x86_64-unknown-linux-musl.
vendored = ["openssl-sys/vendored"]

这样,我可以使用以下方法将其编译为没有库依赖性的单个可执行文件:

This way I can compile to a single executable with no library dependencies using:

cargo build --target=x86_64-unknown-linux-musl --features vendored

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfhggg
系列文章
更多 icon
同类精品
更多 icon
继续加载