交叉编译后缺少共享库的替代解决方案? [英] Alternative solutions to missing shared libraries after cross compilation?

查看:105
本文介绍了交叉编译后缺少共享库的替代解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先交叉编译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 ?

推荐答案

根据 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

这篇关于交叉编译后缺少共享库的替代解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆