Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译错误:OPENSSL_NO_VENDOR unset #121

Open
lauer3912 opened this issue Aug 20, 2022 · 0 comments
Open

编译错误:OPENSSL_NO_VENDOR unset #121

lauer3912 opened this issue Aug 20, 2022 · 0 comments

Comments

@lauer3912
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant