ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

windows 下 Rust 使用OpenSSL

2021-10-30 12:01:19  阅读:77  来源: 互联网

标签:cargo VENDOR no windows openssl OpenSSL OPENSSL build Rust


windows 下 Rust 使用OpenSSL

问题

在cargo.toml 中添加包依赖:

[dependencies]
openssl = { version = "0.10", features = ["vendored"] }

cargo build 之后出现以下错误:

error: failed to run custom build command for `openssl-sys v0.9.68`

Caused by:
  process didn't exit successfully: `xxx\openssl-sys-aaee31d2ea6e39db\build-script-main` (exit code: 101)
  --- stdout
  cargo:rustc-cfg=const_fn
  cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
  X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  running "perl" "./Configure" "--prefix=xxx\\target\\debug\\build\\openssl-sys-fa02faf7b01ccae6\\out\\openssl-build\\install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" 
"no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-engine" "no-asm" "VC-WIN64A"

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', C:\Users\xxx\.cargo\registry\src\github.com-1ecc6299db9ec823\openssl-src-111.16.0+1.1.1l\src\lib.rs:477:39
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

提示找不到指定文件找不到, 有点懵。按文档说法, 使用vendoredfeature会自动编译源码, 并不要求系统安装openssl。

解决

一通折腾之后(包括去掉“verdored”, 使用vcpkg安装openssl都未成功), 才注意到报错信息里有这么一句:

 "perl" "./Configure" "--prefix=xxx\\target\\debug\\build\\openssl-sys-fa02faf7b01ccae6\\out\\openssl-build\\install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" 

说明使用perl程序进行编译配置。查看我当前环境, 并没有安装perl程序。 从 https://strawberryperl.com/ 下载windows安装包,安装后,重启命令行终端, build成功。

标签:cargo,VENDOR,no,windows,openssl,OpenSSL,OPENSSL,build,Rust
来源: https://blog.csdn.net/hh_012345/article/details/121047637

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有