如何在Windows x64上使用openSSL和nghttp2编译cURL? [英] how do I compile cURL with openSSL and nghttp2 on Windows x64?

查看:484
本文介绍了如何在Windows x64上使用openSSL和nghttp2编译cURL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是第一个问题,请耐心等待:)在过去的三天里,我一直在网络上,试图找到一种在Windows机器上获得以下结果的方法.

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.

我需要'cURL -V'输出的示例

我发现了很多用于macOS和Unix的东西,但是对于Windows却只有一点点.我正在运行xampp,最终我试图使它通过cURL/PHP发送http/2请求.到目前为止,我所收集的是我需要使用某些库来编译cURL,例如openssl(至少1.0.2),启用了http/2的libcurl和nghttp2.我觉得我已经很近了,但是我只是缺少一些步骤.

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.

到目前为止我所做的:

  • 为Visual Studio 2017安装了诸如mingw32,cmake和构建工具之类的东西
  • 下载了nghttp2-1.27.0,并使用'cmake'和'cmake --build'获取了5个文件:nghttp2.dll,.exp,.lik,.lib和.pdb
  • 下载了curl-7.56.1.tar.gz( https://curl上的第一个.haxx.se/download.html )
  • 下载了libssh2-1.8.0
  • 下载的openssl-1.0.2l
  • 下载了zlib-1.2.11
  • https://curl.haxx.se/docs/install上遵循Mingw32的说明. html (但始终会显示无法找到openSSL软件包"错误)
  • 我读到某个地方需要用'--with-nghttp2 --prefix- [NGHTTP2 FOLDER HERE的位置]'标志来编译cURL,所以我尝试了一些我认为可行的方法,但我认为它做到了:'cmake --with-nghttp2 --prefix- [此处NGHTTP2文件夹的位置]. ",然后"cmake install". ",它看起来好像做了些什么,但是在curl-7.56.1/src/中内置的cURL.exe除了libcurl之外没有其他任何内容.
  • 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 :)

推荐答案

好吧,我终于能够在Windows上通过http/2支持构建Curl. 这是逐步为我工作的方法:

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:谢谢Daniel指出了我正确的方向.我什至没有注意到/winbuild目录.

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

PPS:您可能会说,我不知道我90%的时间在做什么.大概是为什么我花了5天时间才弄清楚;)

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 ;)

这篇关于如何在Windows x64上使用openSSL和nghttp2编译cURL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆