Building cURL + HTTP/2 on Windows (A hackabout way)

What

This is a very quick and dirty set of notes for building curl.exe that includes HTTP/2 (via –http2) support on Windows. This is a “make it work” path, not something elegant!. For me, this came in handy testing against a h2o HTTP/2 server using h2c (browsers want to use h2 only).

I’ll say this one more time: This is a dirty dirty hack I used just to get the thing built so I could move on to more pressing issues :)

Prerequisites

  • A modernish Visual Studio
  • OpenSSL 1.0.0+ built somewhere*
  • nghttp2 built somewhere*
  • zlib built somewhere* (If you want gzip support of course)
  • Outside the scope of this quick and dirty article!

The basic instructions

  1. Checkout the latest cURL from Github
  2. From projects, run generate.bat … wait for a bit.
  3. Open the proper solution for your VC version
  4. Select the proper configuration such as “LIB Release - DLL OpenSSL”
  5. Modify the libcurl project adding the following defines: USE_NGHTTP2=1, NGHTTP2_STATICLIB=1
  6. Modify the same project pointing to OpenSSL and nghttp2 include and lib folders as well as to link against your nghttp2.lib
  7. Build!

If all goes well, you now have a curl.exe that supports –http2!

gzip

Gzip compression can be enabled by similar steps to above, but add HAVE_ZLIB_H=1, HAVE_LIBZ=1, USE_ZLIB=1 to your preprocessor and point to the appropriate zlib locations.