解决在 Windows 上 openssl-sys 构建失败的问题
36
2024-09-16
问题
在 Windows 下构建时抛出了下方错误,意思就是缺少 OpenSSL 这个玩意儿,如果在 Linux 平台直接用包管理工具安装就 OK 了,但是在 Windows 平台则需要手动操作。
OPENSSL_DIR unset
note: vcpkg did not find openssl: Could not look up details of packages in vcpkg tree could not read status file updates dir: 系统找不到指定的路径。 (os error 3)
--- stderr
thread 'main' panicked at C:\Users\mark\.cargo\registry\src\index.crates.io-6f17d22bba15001f\openssl-sys-0.9.103\build\find_normal.rs:190:5:
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.
If you're in a situation where you think the directory *should* be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.
$HOST = aarch64-pc-windows-msvc
$TARGET = aarch64-pc-windows-msvc
openssl-sys = 0.9.103
It looks like you're compiling for MSVC but we couldn't detect an OpenSSL
installation. If there isn't one installed then you can try the rust-openssl
README for more information about how to download precompiled binaries of
OpenSSL:
https://github.com/sfackler/rust-openssl#windows
解决方法
使用的 choco 安装,如果没有 choco 见 这篇文章 快速安装。
choco install openssl
安装完之后,还需要设置环境变量
OPENSSL_DIR: C:\Program Files\OpenSSL-Win64
OPENSSL_LIB_DIR:C:\Program Files\OpenSSL-Win64\lib\VC\x64\MD
最后,重启 VSCode 再构建就行了。
引用
- 0
- 0
-
分享