Enabling OpenSSL for Rust in Windows

Posted on . Reading time: 2 mins. Tags: rust, openssl, windows.

The other day I was compiling a Rust project on a Windows 11 environment, and when executing cargo run and I got the following error:

error: failed to run custom build command for openssl-sys v0.9.93
note: vcpkg did not find openssl: Could not find Vcpkg tree: No vcpkg installation found. Set the VCPKG_ROOT environment variable or run 'vcpkg integrate install'

According to the openssl crate documentation, you can locate the OpenSSL libraries using 3 ways: vendored, automatic or manual.

I didn't want to use the vendored option because I didn't want to modify that project's Cargo.toml.

First I tried the automatic way, which consisted on:

  1. Installing vcpkg.
  2. Executing ./vcpkg/vcpkg.exe install openssl

But that was not enough. It was still failing to locate the OpenSSL library. So I ended following the instructions for the manual approach. This approach required me to not only perform the two steps mentioned above of the automatic approach, but also set the following environment variables:


After that, cargo was happy and everything worked as expected!