Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Mecanik/06aa38b638316d8840b685eb1474ad7d to your computer and use it in GitHub Desktop.
Save Mecanik/06aa38b638316d8840b685eb1474ad7d to your computer and use it in GitHub Desktop.
Build CURL with Visual Studio 2019 and OpenSSL 3.0 (Windows)

Build CURL with Visual Studio 2019 and OpenSSL 3.0 (Windows)

How to build libcurl is a very popular search term, and frankly there is so much banana "tutorials" that I`m sick of it.

CURL is already configured on windows to search for openssl folder in the following order:

  • curl folder
  • openssl folder

However this means you would need to build openssl yourself and match what CURL is looking for. If you look into Additional Include directories inside the visual studio project you will see:

..\..\..\..\include;
..\..\..\..\lib;
..\..\..\..\..\openssl\include\..\build\Win32\VC15\LIB Debug\include;
..\..\..\..\..\openssl\include;

With that being said, we can get away much easier than to build OpenSSL ourselves.

Building Libcurl

  1. Go to this website and download the larger installer which includes OpenSSL libs: https://slproweb.com/products/Win32OpenSSL.html
  2. Install the content wherever you'd like (I recommend choosing the option to copy the .dlls into /bin directory and installing in program files)
  3. Now add the paths to the Additional Include directories in the visual studio project:
..\..\..\..\include;
..\..\..\..\lib;
..\..\..\..\..\openssl\include\..\build\Win32\VC15\LIB Debug\include;
..\..\..\..\..\openssl\include;
C:\Program Files (x86)\OpenSSL-Win32\include;

Change paths accordingly, in my scenario I was building LIB Debug - LIB OpenSSL under x32. If you are building x64 then just follow the same steps and replace the paths accordingly (C:\Program Files\ instead of C:\Program Files (x86)).

The visual studio project can now find the required header files (.h) and compile for you libcurld.lib without anything else to do.

Building curl

In order to compile the curl executable as well (if you need it), we need to change the library names in the visual studio project to match what we installed (installing OpenSSL from this website has the library names including 32/64) and add the path to these libraries.

  1. Go to VC++ Directories -> Library Directories and add: C:\Program Files (x86)\OpenSSL-Win32\lib\VC\static
  2. Change the library names from:
libcrypto.lib
libssl.lib

Into:

libcrypto32MTd.lib
libssl32MTd.lib

Pay attention here, because the library names are named according to the compilation type (MT (static) + d (debug). Libucrl is configured to build as Multi-threaded Debug DLL (/MDd) (NOT STATIC - WHY DOES THE WEBSITE SAY STATIC?), so change it to Multi-threaded Debug (/MTd).

If you are building for Release and Static mode you need use:

libcrypto32MT.lib
libssl32MT.lib

That's all, ENJOY!

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