Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I compile cURL with openSSL and nghttp2 on Windows x64?

first question ever on here, so bear with me :) I've been on the web for the past 3 days trying to find a way to get the following result on my windows machine.

example of 'cURL -V' output I need

I've found a lot of stuff for macOS and unix, but only bits and pieces for Windows. I'm running xampp, and ultimately I'm trying to get it to send http/2 requests through cURL/PHP. What I've gathered so far is that I need cURL to be compiled with some libraries, like openssl (at least 1.0.2), libcurl with http/2 enabled, and nghttp2. I feel like I'm very close but I'm just missing some steps.

What I've done so far:

  • installed things like mingw32, cmake, and Build Tools for Visual Studio 2017
  • downloaded nghttp2-1.27.0, and used 'cmake' and 'cmake --build' to get the 5 files: nghttp2.dll, .exp, .lik, .lib, and .pdb
  • downloaded curl-7.56.1.tar.gz (the very first one on https://curl.haxx.se/download.html)
  • downloaded libssh2-1.8.0
  • downloaded openssl-1.0.2l
  • downloaded zlib-1.2.11
  • followed instructions for Mingw32 on https://curl.haxx.se/docs/install.html (but it keeps giving me the error 'cannot find openSSL package')
  • I read somewhere that I need to compile cURL with the '--with-nghttp2 --prefix-[LOCATION OF NGHTTP2 FOLDER HERE]' flag, so I tried something that I thought would work, but I don't think it did: 'cmake --with-nghttp2 --prefix-[LOCATION OF NGHTTP2 FOLDER HERE] . ', then 'cmake install . ' and it looked like it did something, but the cURL.exe that was built inside curl-7.56.1/src/ did not have anything else but libcurl.

Any suggestions or pointers will be greatly appreciated! Thank you guys :)

like image 997
Merricat Avatar asked Mar 07 '23 17:03

Merricat


1 Answers

Ok, I was finally able to build Curl on Windows with http/2 support. This is what worked for me, step by step:

  • Downloaded "Build Tools for Visual Studio 2017" to be able to build from the command line (provides nmake and required Windows SDK libraries and header filtes)
  • downloaded the latest version of curl, like stated above (curl-7.56.1.tar.gz, aka for me the very first one on https://curl.haxx.se/download.html)
  • extracted it inside c:/curl, so I ended up with c:/curl/curl-7.56.1
  • read instructions BUILD.WINDOWS.txt inside c:/curl/curl-7.56.1/winbuild and proceeded to http://windows.php.net/downloads/php-sdk/deps/ to download the 4 libraries that I needed. I just grabbed the VC15/x86 versions.
  • created a new folder named "deps" inside c:/curl/curl-7.56.1
  • created the following 3 folders inside c:/curl/curl-7.56.1/deps: bin, lib, and include
  • extracted each library I just downloaded in the corresponding 3 folders
  • opened Developer Command Prompt for VS 2017
  • cd c:/curl/curl-7.56.1/winbuild
  • nmake -f Makefile.vc mode=dll WITH_DEVEL=c:/curl/curl-7.56.1/deps WITH_SSL=dll WITH_NGHTTP2=dll WITH_ZLIB=static WITH_SSH2=dll
  • this builds a CURL executable inside one of the subfolders in c:\curl\curl-7.56.1\builds
  • when I first tried running CURL, it showed an error saying missing libssl-1_1.dll and libcrypto-1_1.dll, so I had to copy them from c:\curl\curl-7.56.1\deps\bin to the same directory where the newly built curl.exe is
  • Note: since zlib didn't come with a bin folder containing any .dll's, I understand why I had to mark zlib as static with the WITH_ZLIB=static flag. What I don't get is why I had to manually move the openssl .dll's in the new directory. Any thoughts?

PS: thank you Daniel for pointing me in the right direction. I didn't even notice the /winbuild directory.

PPS: As you can probably tell, I had no idea what I've been doing 90% of the time. Probably why it took me 5 days to figure it out ;)

like image 160
Merricat Avatar answered Mar 11 '23 18:03

Merricat