gpt4 book ai didi

ssl - 为什么 reqwest 需要安装 OpenSSL?

转载 作者:行者123 更新时间:2023-11-29 08:15:50 26 4
gpt4 key购买 nike

我试图让一个基本的 reqwest http-request 像这样进行

extern crate reqwest;
extern crate url;

use url::Url;

fn main() {
let resp = reqwest::get("http://google.com".parse::<Url>().unwrap());
println!("{:?}", resp.unwrap())
}

但是,这会产生错误

Could not find directory of OpenSSL installation, and this -sys crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set the OPENSSL_DIR environment variable for the compilation process.

Make sure you also have the development packages of openssl installed. For example, libssl-dev on Ubuntu or openssl-devel on Fedora.

...

好吧,这很容易修复。一次调用 sudo apt install libssl-devsudo apt install pkg-config 就可以了。但我仍然不明白这里到底出了什么问题。我认为 cargo 应该处理依赖关系。为什么我现在要使用 apt 手动搜索它们?

最佳答案

reqwest depends on rust-native-tls ,这on Linux depends on openssl-sys ,即 where this message comes from .所以 cargo 确实完成了它的工作,处理了 Rust 依赖项。

但是,openssl-sys 依赖于 C 库 (OpenSSL),此时 cargo 停止关心。

关于ssl - 为什么 reqwest 需要安装 OpenSSL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52238397/

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