<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Vcpkg on kenji.blog</title><link>http://kenji.blog/zh-cn/tags/vcpkg/</link><description>Recent content in Vcpkg on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><copyright>kenjinote</copyright><lastBuildDate>Mon, 07 Jul 2025 21:46:08 +0900</lastBuildDate><atom:link href="http://kenji.blog/zh-cn/tags/vcpkg/index.xml" rel="self" type="application/rss+xml"/><item><title>【面向初学者】使用vcpkg在Visual Studio中安装libcurl（支持OpenSSL）的步骤</title><link>http://kenji.blog/zh-cn/p/vcpkg-%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6-visual-studio-%E3%81%AB-curl-%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/</link><pubDate>Mon, 07 Jul 2025 21:46:08 +0900</pubDate><guid>http://kenji.blog/zh-cn/p/vcpkg-%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6-visual-studio-%E3%81%AB-curl-%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/</guid><description>&lt;img src="http://kenji.blog/p/vcpkg-%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6-visual-studio-%E3%81%AB-curl-%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/img.png" alt="Featured image of post 【面向初学者】使用vcpkg在Visual Studio中安装libcurl（支持OpenSSL）的步骤" />&lt;h2 id="在visual-studio中使用libcurl支持openssl推荐使用简单易用的vcpkg">在Visual Studio中使用libcurl（支持OpenSSL），推荐使用简单易用的vcpkg
&lt;/h2>&lt;p>在C++中处理HTTP通信时，经常会用到 &lt;code>libcurl&lt;/code>。但是，构建和调整依赖关系往往出乎意料地麻烦。&lt;/p>
&lt;p>这时候派上用场的就是微软出品的C++库管理工具“&lt;strong>vcpkg&lt;/strong>”。
这次，我们将介绍使用 &lt;code>vcpkg&lt;/code> 安装 &lt;code>libcurl&lt;/code>（支持OpenSSL），并在Visual Studio中顺畅使用的步骤。&lt;/p>
&lt;hr>
&lt;h3 id="安装vcpkg仅限未安装的用户">安装vcpkg（仅限未安装的用户）
&lt;/h3>&lt;p>首先来安装 &lt;code>vcpkg&lt;/code>。请在 PowerShell 中执行以下步骤。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">git&lt;/span> &lt;span class="n">clone&lt;/span> &lt;span class="n">https&lt;/span>&lt;span class="err">:&lt;/span>&lt;span class="p">//&lt;/span>&lt;span class="n">github&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">com&lt;/span>&lt;span class="p">/&lt;/span>&lt;span class="n">microsoft&lt;/span>&lt;span class="p">/&lt;/span>&lt;span class="n">vcpkg&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">cd &lt;/span>&lt;span class="n">vcpkg&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">.\&lt;/span>&lt;span class="nb">bootstrap-vcpkg&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="py">bat&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>※如果尚未安装Git，请从&lt;a class="link" href="https://git-scm.com/" target="_blank" rel="noopener"
>Git官网&lt;/a>进行安装。&lt;/p>
&lt;hr>
&lt;h3 id="安装libcurl支持openssl">安装libcurl（支持OpenSSL）
&lt;/h3>&lt;p>接下来，使用vcpkg安装 &lt;code>libcurl&lt;/code>。要指定支持OpenSSL的64位版本，请执行以下命令：&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">vcpkg&lt;/span> &lt;span class="n">install&lt;/span> &lt;span class="n">curl&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="no">ssl&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-triplet&lt;/span> &lt;span class="nb">x64-windows&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>执行此命令后，所需的依赖项（如OpenSSL等）也会自动设置。&lt;/p>
&lt;hr>
&lt;h3 id="与visual-studio的集成设置">与Visual Studio的集成设置
&lt;/h3>&lt;p>为了在Visual Studio项目中方便地使用通过vcpkg安装的库，请使用以下命令进行集成设置。&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">vcpkg&lt;/span> &lt;span class="n">integrate&lt;/span> &lt;span class="n">install&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>进行此设置后，在Visual Studio项目中将自动可以使用 &lt;code>#include &amp;lt;curl/curl.h&amp;gt;&lt;/code>，无需再手动配置库路径或链接器设置。&lt;/p>
&lt;hr>
&lt;h2 id="结语">结语
&lt;/h2>&lt;p>至此，在Visual Studio中安装 &lt;code>libcurl&lt;/code>（支持OpenSSL）的准备工作就完成了。&lt;/p>
&lt;ul>
&lt;li>使用vcpkg，可以统一管理麻烦的依赖关系&lt;/li>
&lt;li>通过 &lt;code>vcpkg install curl[ssl] --triplet x64-windows&lt;/code> 轻松安装libcurl&lt;/li>
&lt;li>通过 &lt;code>vcpkg integrate install&lt;/code> 即可实现与Visual Studio的自动集成&lt;/li>
&lt;/ul>
&lt;p>接下来，只需在项目中包含头文件，并使用libcurl的API开始开发吧。
充分利用方便的vcpkg，一口气提高开发效率吧。&lt;/p></description></item></channel></rss>