windows 下 Rust 使用OpenSSL

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成功。

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值