解决rust编译目标为musl时openssl报错
2022/4/11 6:14:27
本文主要是介绍解决rust编译目标为musl时openssl报错,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
同步:https://zhufn.fun/archives/rust-musl-ssl/
为了节省容器启动时间,准备把rust写的api编译好后扔进docker里,于是编译到target:x86_64-unknown-linux-musl
然后openssl炸了,不认libssl-dev了,查了下要重新编译。。。
但是,我们发现了一个神奇的docker镜象https://github.com/emk/rust-musl-builder,它已经配好了openssl的musl环境以及diesel, sqlx
于是只要这样:
alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder' rust-musl-builder cargo build --release
就可以了
(不过好像也可以把openssl换成rustls来解决)
However, rustls now works well with most of the Rust ecosystem, including reqwest, tokio, tokio-postgres, sqlx and many others. The only major project which still requires libpq and OpenSSL is Diesel. If you don't need diesel or libpq:
See if you can switch away from OpenSSL, typically by using features in Cargo.toml to ask your dependencies to use rustls instead.
If you don't need OpenSSL, try cross build --target=x86_64-unknown-linux-musl --release to cross-compile your binaries for libmusl. This supports many more platforms, with less hassle!
这篇关于解决rust编译目标为musl时openssl报错的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南