交叉编译后缺少共享库的替代解决方案?
Alternative solutions to missing shared libraries after cross compilation?
我首先 cross 将我的 Rust 项目编译到 linux 目标
cargo build --target x86_64-unknown-linux-gnu
然后 运行 ldd
在我的本地 ubuntu 上,链接器工作正常。
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)
但是在我的目标 os 上,ldd
找不到库
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
的共享库。
我已阅读 Rust Cross,推荐的解决方案是安装缺少的共享库。不幸的是,这对我来说不是 possible。所以我正在寻找缺失库的替代解决方案。
libssl.so.1.0.0
和 libcrypto.so.1.0.0
听起来很古老。我怎样才能告诉 cargo
使用更高版本?
如何处理/lib64/libc.so.6 => version GLIBC_2.18 not found
?
根据 this,GLIBC_2.18
无法安装到 RHEL7
。我放弃了动态链接库。
这个 post 帮助了我。解决方案是:
[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"]
这样我就可以编译成一个没有库依赖的可执行文件:
cargo build --target=x86_64-unknown-linux-musl --features vendored
我首先 cross 将我的 Rust 项目编译到 linux 目标
cargo build --target x86_64-unknown-linux-gnu
然后 运行 ldd
在我的本地 ubuntu 上,链接器工作正常。
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)
但是在我的目标 os 上,ldd
找不到库
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
的共享库。
我已阅读 Rust Cross,推荐的解决方案是安装缺少的共享库。不幸的是,这对我来说不是 possible。所以我正在寻找缺失库的替代解决方案。
libssl.so.1.0.0
和 libcrypto.so.1.0.0
听起来很古老。我怎样才能告诉 cargo
使用更高版本?
如何处理/lib64/libc.so.6 => version GLIBC_2.18 not found
?
根据 this,GLIBC_2.18
无法安装到 RHEL7
。我放弃了动态链接库。
这个 post 帮助了我。解决方案是:
[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"]
这样我就可以编译成一个没有库依赖的可执行文件:
cargo build --target=x86_64-unknown-linux-musl --features vendored