如何在 Windows x64 上使用 openSSL 和 nghttp2 编译 cURL? [英] how do I compile cURL with openSSL and nghttp2 on Windows x64?
问题描述
这里的第一个问题,请耐心等待 :) 过去 3 天我一直在网上试图找到一种在我的 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.
我找到了很多适用于 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.
到目前为止我做了什么:
What I've done so far:
- 为 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-[LOCATION OF NGHTTP2 FOLDER HERE]' 标志编译 cURL,所以我尝试了一些我认为可行的方法,但我不认为它做到了:'cmake --with-nghttp2 --prefix-[NGHTTP2 文件夹的位置].',然后是 'cmake 安装.' 看起来它做了一些事情,但是在 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 :)
推荐答案
好的,我终于能够在支持 http/2 的 Windows 上构建 Curl.这对我有用,一步一步:
Ok, I was finally able to build Curl on Windows with http/2 support. This is what worked for me, step by step:
- 已下载Visual Studio 2017 构建工具" 以便能够从命令行构建(提供
nmake
和所需的 Windows SDK 库和头文件) - 下载了最新版本的 curl,如上所述(
curl-7.56.1.tar.gz
,对我来说也是 https://curl.haxx.se/download.html) - 在
c:/curl
中提取它,所以我最终得到了c:/curl/curl-7.56.1
- 阅读
c:/curl/curl-7.56.1/winbuild
内的说明BUILD.WINDOWS.txt,然后继续http://windows.php.net/downloads/php-sdk/deps/ 下载我需要的4个库.我刚拿到了 VC15/x86 版本. - 在
c:/curl/curl-7.56.1
中创建了一个名为deps"的新文件夹 - 在
c:/curl/curl-7.56.1/deps
内创建了以下 3 个文件夹:bin
、lib
和包括
- 将我刚下载的每个库都提取到对应的3个文件夹中
- 为 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
- 这会在
c:curlcurl-7.56.1uilds
的一个子文件夹中构建一个 CURL 可执行文件 - 当我第一次尝试运行 CURL 时,它显示一个错误,提示缺少 libssl-1_1.dll 和 libcrypto-1_1.dll,所以我不得不从
c:curlcurl-7.56.1depsin
到新建curl.exe所在目录 - 注意:由于 zlib 没有包含任何
.dll
的bin
文件夹,我明白为什么我必须使用WITH_ZLIB=static
标志.我不明白为什么我必须手动将 openssl.dll
移动到新目录中.有什么想法吗?
- 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 withc:/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
, andinclude
- 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:curlcurl-7.56.1uilds
- 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:curlcurl-7.56.1depsin
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 theWITH_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屋!