Skip to content

Instantly share code, notes, and snippets.

@retep998
Last active December 26, 2020 03:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retep998/eeca39710290d294c81f38e8f8490801 to your computer and use it in GitHub Desktop.
Save retep998/eeca39710290d294c81f38e8f8490801 to your computer and use it in GitHub Desktop.

Installing OpenSSL for Rust on Windows with MSVC

When using MSVC Rust on Windows, everything typically works out of the box, up until you decide to do some web stuff with hyper. Suddenly a new dependency, openssl, is failing to build and you have no idea how to fix it. Fortunately this guide is here to save you!

WARNING: OpenSSL 1.1 support was only added in openssl-sys = "0.9". Older versions only support up to OpenSSL 1.0.2. sfackler/rust-openssl#452

  1. First you will need to download and install OpenSSL itself. You can download an installer from http://slproweb.com/products/Win32OpenSSL.html. In particular you want the newest version and not the light version. Make sure it matches the version of Rust you have, if you're using x86_64-pc-windows-msvc you will want Win64, and if you're using i9686-pc-windows-msvc you will want Win32. For the purpose of example I have installed Win64 OpenSSL v1.0.2h.
  2. If all went well you should now have OpenSSL installed somewhere. For me it is C:\OpenSSL-Win64. Inside are three important folders, bin include and lib.
  3. You will want to set several environment variables, the values of which will depend on where you installed OpenSSL. For me I set them like so:
  • OPENSSL_LIB_DIR = C:\OpenSSL-Win64\lib
  • OPENSSL_INCLUDE_DIR = C:\OpenSSL-Win64\include
  • OPENSSL_LIBS = libeay32:ssleay32
  • OPENSSL_DIR = C:\OpenSSL-Win64
  • Add C:\OpenSSL-Win64\bin to PATH.
  1. Do a clean build of your project by doing cargo clean and cargo build.
  2. If you're still having issues with OpenSSL, find me so I can figure out what you did wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment