Fail to build 'openssl-sys' on win10

I‘m working on a project which depency on openssl-sys in Windows, but it didn't work.There is error:

error: failed to run custom build command for openssl-sys v0.9.78
Caused by:
process didn't exit successfully: C:\Users\Administrator\Downloads\espflash-main\target\debug\build\openssl-sys-c1a48d73a93e76d4\build-script-main (exit code: 101)
--- stdout
running "perl" "./Configure" "--prefix=C:\Users\Administrator\Downloads\espflash-main\target\debug\build\openssl-sys-40293905b51895d6\out\openssl-build\install" "--openssldir=SYS$MANAGER:[OPENSSL]" "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: Error { kind: NotFound, message: "program not found" }', C:\Users\Administrator.cargo\registry\src\\openssl-src-111.24.0+1.1.1s\src\

Then I reference the issue in github, following the steps, I install MSYS2, and install MINGW64 and its tools, but get the same result. Indeed, I configue the enviroment varible like this. But still didn't work......TAT

Is there a solution? I'm a new man for rust, if there are some obvious mistakse , please give me a favor.Thank all of you!

One option might be to use rustls instead. Many crates that use OpenSSL offer feature flags to switch to Rustls. As you've seen, OpenSSL can be troublesome to set up sometimes, whereas Rustls is just a Rust crate, so it's easy to include in any project.

It is trying to build openssl, and for that it needs a perl interpreter.

If you want to allow it to build its own openssl but don't feel like installing perl just for that, there's a "portable" version of Strawberry Perl that you can unpack somewhere and then point PATH to.

Generally speaking, I haven't had much success with -sys crates finding manually installed libraries on Windows. My go-to solution these days is to use vcpkg and, for the odd crate like gtk, a manually installed pkg-config-lite.

Enabling the vendored flag and restarting VS Code fixed it for me

openssl = { version = "0.10.45", features = ["vendored"] }

I also have Strawberry Perl installed

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.