使用支持 HTTP2 的 windows 构建 libcurl

Posted

技术标签:

【中文标题】使用支持 HTTP2 的 windows 构建 libcurl【英文标题】:build libcurl with windows with HTTP2 support 【发布时间】:2021-10-06 14:27:45 【问题描述】:

我正在尝试通过 Microsoft 可视化构建工具安装支持 HTTP2 的 libcurl。看起来,使用 ubuntu,你可以使用 --with-http2=path/to-nghttp2。但我无法执行该命令,并且我不知道 Windows 中的等效命令。我已经安装了 nghttp2 和 openssl。我应该在原生构建工具的哪个位置插入告诉 libcurl 构建支持 http2 的命令?

尝试这样做不起作用nmake /f Makefile.vc mode=static vc=16 debug=no DUSE_NGHTTP2=OFF。该库构建但不允许 http2 请求。使用 curl cli 时,使用此选项后它不会给我错误代码 1) 不受支持的协议,但不会使用 HTTP2。也试过 DUSE_NGHTTP2=ON

C:\Users\ball\Desktop\curl\curl-7.79.1\winbuild>nmake /f Makefile.vc mode=static vc=16 debug=no MACHINE=x64 WITH_NGHTTP2=static NGHTTP2_PATH="C:\\Users\\ball\\Desktop\\nghttp2\\nghttp2-1.45.1\\lib\\includes\\"

Microsoft (R) Program Maintenance Utility Version 14.29.30133.0
Copyright (C) Microsoft Corporation.  All rights reserved.

configuration name: libcurl-vc16-x64-release-static-ipv6-sspi-schannel-nghttp2-static
        cl /O2 /DNDEBUG /MT /DCURL_STATICLIB /I. /I ../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL  /DUSE_WIN32_IDN /DWANT_IDN_PROTOTYPES  /DUSE_IPV6  /DUSE_WINDOWS_SSPI /DUSE_SCHANNEL /DUSE_NGHTTP2 /DNGHTTP2_STATICLIB /I"C:\\Users\\ball\\Desktop\\nghttp2\\nghttp2-1.45.1\\lib\\includes\\include" /Fo"..\builds\libcurl-vc16-x64-release-static-ipv6-sspi-schannel-nghttp2-static-obj-lib/altsvc.obj"  ..\lib\altsvc.c
altsvc.c
C:\Users\ball\Desktop\curl\curl-7.79.1\lib\http.h(38): fatal error C1083: Cannot open include file: 'nghttp2/nghttp2.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.

C:\Users\ball\Desktop\curl\curl-7.79.1\winbuild>```

我也尝试过使用单个黑斜线并且没有 qoutes... 我可以确认文件夹和文件存在并且在此路径中:C:\Users\ball\Desktop\nghttp2\nghttp2-1.45.1\lib\包括\nghttp2\nghttp2.h

【问题讨论】:

【参考方案1】:

CMake 选项是-DUSE_NGHTTP2=ON

Nmake 选项是WITH_NGHTTP2=dllWITH_NGHTTP2=static

nmake /f Makefile.vc mode=static vc=16 debug=no WITH_NGHTTP2=dll

【讨论】:

查看更新的答案@S.M. 我不知道你在做什么。 curl 在源代码中没有 Makefile.vc。 如前所述,我正在使用 mc 构建工具,这意味着我在 Windows 上。你可以在'curl_version'的winbuild文件夹中找到Makefile.vc @noah 谢谢,我从来没有对 winbind 目录感兴趣。所以,你知道的,你为什么不去那里关注README.md? 请查看更新的答案

以上是关于使用支持 HTTP2 的 windows 构建 libcurl的主要内容,如果未能解决你的问题,请参考以下文章

Delphi 的 TNetHTTPClient 后代支持 http2

tengine配置支持http2

Windows环境下Nginx配置HTTP/2.0

Java 9 HTTP2的支持功能前瞻

深入理解 WEB协议HTTP2

如何使用 Apache 2.4.23 在 CentOs Server 中实现 http2 (h2)?