<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Curl on kenji.blog</title><link>http://kenji.blog/en/tags/curl/</link><description>Recent content in Curl on kenji.blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>kenjinote</copyright><lastBuildDate>Mon, 07 Jul 2025 21:46:08 +0900</lastBuildDate><atom:link href="http://kenji.blog/en/tags/curl/index.xml" rel="self" type="application/rss+xml"/><item><title>[For Beginners] Steps to Install libcurl (with OpenSSL support) in Visual Studio using vcpkg</title><link>http://kenji.blog/en/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/en/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 [For Beginners] Steps to Install libcurl (with OpenSSL support) in Visual Studio using vcpkg" />&lt;h2 id="for-using-libcurl-with-openssl-support-in-visual-studio-vcpkg-is-easy-and-recommended">For using libcurl (with OpenSSL support) in Visual Studio, vcpkg is easy and recommended
&lt;/h2>&lt;p>When you want to handle HTTP communication in C++, &lt;code>libcurl&lt;/code> is often used. However, adjusting builds and dependencies can be unexpectedly troublesome, right?&lt;/p>
&lt;p>In such cases, the Microsoft-made C++ library management tool &amp;ldquo;&lt;strong>vcpkg&lt;/strong>&amp;rdquo; is very useful.
This time, we will introduce the steps from introducing &lt;code>libcurl&lt;/code> (with OpenSSL support) using &lt;code>vcpkg&lt;/code> to making it smooth to use in Visual Studio.&lt;/p>
&lt;hr>
&lt;h3 id="installing-vcpkg-only-for-those-who-havent-installed-it-yet">Installing vcpkg (Only for those who haven&amp;rsquo;t installed it yet)
&lt;/h3>&lt;p>First, let&amp;rsquo;s install &lt;code>vcpkg&lt;/code>. Please run the following steps in 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;ul>
&lt;li>If Git is not installed yet, please install it from the &lt;a class="link" href="https://git-scm.com/" target="_blank" rel="noopener"
>Git official website&lt;/a>.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="installing-libcurl-with-openssl-support">Installing libcurl (with OpenSSL support)
&lt;/h3>&lt;p>Next, we will use vcpkg to install &lt;code>libcurl&lt;/code>. To specify the 64bit version with OpenSSL support, run the following command.&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>When this command is run, necessary dependencies (such as OpenSSL) are also set up automatically.&lt;/p>
&lt;hr>
&lt;h3 id="integration-settings-with-visual-studio">Integration settings with Visual Studio
&lt;/h3>&lt;p>To easily use the library introduced by vcpkg from a Visual Studio project, configure the integration setting with the following command.&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>By doing this setting, &lt;code>#include &amp;lt;curl/curl.h&amp;gt;&lt;/code> can be automatically used in Visual Studio projects, eliminating the need to manually set up library paths and linker settings.&lt;/p>
&lt;hr>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>With this, the preparation to introduce &lt;code>libcurl&lt;/code> (with OpenSSL support) into Visual Studio is complete.&lt;/p>
&lt;ul>
&lt;li>With vcpkg, troublesome dependencies can be managed all at once.&lt;/li>
&lt;li>Easily introduce libcurl with &lt;code>vcpkg install curl[ssl] --triplet x64-windows&lt;/code>&lt;/li>
&lt;li>Automatic integration with Visual Studio is possible with &lt;code>vcpkg integrate install&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>After this, just include the header in your project and start developing using the libcurl API.
Please utilize the convenient vcpkg and dramatically increase your development efficiency.&lt;/p></description></item><item><title>Send Gmail from curl</title><link>http://kenji.blog/en/p/gmail%E3%82%92curl%E3%81%8B%E3%82%89%E9%80%81%E3%82%8B/</link><pubDate>Thu, 27 Feb 2025 02:13:31 +0900</pubDate><guid>http://kenji.blog/en/p/gmail%E3%82%92curl%E3%81%8B%E3%82%89%E9%80%81%E3%82%8B/</guid><description>&lt;img src="http://kenji.blog/p/gmail%E3%82%92curl%E3%81%8B%E3%82%89%E9%80%81%E3%82%8B/img.png" alt="Featured image of post Send Gmail from curl" />&lt;h1 id="send-gmail-from-curl">Send Gmail from curl
&lt;/h1>&lt;h2 id="1-get-an-app-password">1. Get an App Password
&lt;/h2>&lt;p>&lt;a class="link" href="https://myaccount.google.com/apppasswords" target="_blank" rel="noopener"
>https://myaccount.google.com/apppasswords&lt;/a>
Click the link above and enter an app name.
Save the generated password.&lt;/p>
&lt;h2 id="2-send-an-email-with-the-curl-command">2. Send an email with the curl command
&lt;/h2>&lt;p>Run the following command.&lt;/p>
&lt;p>In the example below, the email content is written in &lt;code>mail.txt&lt;/code>.&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;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-mail.txt" data-lang="mail.txt">&lt;span class="line">&lt;span class="cl">From: from@gmail.com
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">To: to@gmail.com
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Subject: Test Email
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Content-Type: text/plain; charset=&amp;#34;UTF-8&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">This is a test email.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Create the above file and run the following command.&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-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl --url &lt;span class="s2">&amp;#34;smtps://smtp.gmail.com:465&amp;#34;&lt;/span> --ssl-reqd --mail-from &lt;span class="s2">&amp;#34;from@gmail.com&amp;#34;&lt;/span> --mail-rcpt &lt;span class="s2">&amp;#34;to@gmail.com&amp;#34;&lt;/span> --user &lt;span class="s2">&amp;#34;from@gmail.com:xxxxxxxxxxxxxxxx&amp;#34;&lt;/span> --upload-file mail.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>Replace xxxxxxxxxxxxxxxx with your app password.&lt;/li>
&lt;/ul></description></item><item><title>Generate QR code with curl</title><link>http://kenji.blog/en/p/curl%E3%81%A7qr%E3%82%B3%E3%83%BC%E3%83%89%E7%94%9F%E6%88%90/</link><pubDate>Tue, 16 Apr 2024 00:42:27 +0900</pubDate><guid>http://kenji.blog/en/p/curl%E3%81%A7qr%E3%82%B3%E3%83%BC%E3%83%89%E7%94%9F%E6%88%90/</guid><description>&lt;img src="http://kenji.blog/p/curl%E3%81%A7qr%E3%82%B3%E3%83%BC%E3%83%89%E7%94%9F%E6%88%90/img.png" alt="Featured image of post Generate QR code with curl" />&lt;h2 id="generate-qr-code-with-curl">Generate QR code with curl
&lt;/h2>&lt;p>Note: The method introduced below generates the QR code on the server side and returns it, so logs might be kept. Please be careful when converting confidential information such as personal information into a QR code.&lt;/p>
&lt;h3 id="method-1">Method 1
&lt;/h3>&lt;p>This is a method to generate a QR code in the command prompt.
&lt;code>qrenco.de&lt;/code> returns a text-based response.&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-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">curl qrenco.de/kenji.blog
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>Output result&lt;/li>
&lt;/ul>
&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;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">█████████████████████████████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">█████████████████████████████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████ ▄▄▄▄▄ █ ▄ ▄ █ ▄▄▄▄▄ ████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████ █ █ █ ▀▀▀██ █ █ ████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████ █▄▄▄█ █▀▀█▀▄█ █▄▄▄█ ████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████▄▄▄▄▄▄▄█▄▀ ▀ █▄▄▄▄▄▄▄████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████▄ █▀▄ ▄▀█▄▀ ▀██▄▀ ▄████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████▀▀▀█ ▄▄ ▄█▄█▀█▀▄██ ▀████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████▄▄▄██▄▄█ █▀█ ▄██▀▀█ █████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████ ▄▄▄▄▄ █▀█ ▀ ▄▀▄▄▄ ▀████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████ █ █ █▄▄ ▄▀▄▀▄ ██ ▀████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████ █▄▄▄█ █▀▀█ ▀▄▄▄ ▄▄██████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">████▄▄▄▄▄▄▄█▄▄███▄▄█▄███▄████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">█████████████████████████████
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">█████████████████████████████
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h4 id="reference">Reference
&lt;/h4>&lt;ul>
&lt;li>&lt;a class="link" href="https://qrenco.de/" target="_blank" rel="noopener"
>qrenco.de&lt;/a>&lt;/li>
&lt;/ul>
&lt;h3 id="method-2">Method 2
&lt;/h3>&lt;p>&lt;code>api.qrserver.com&lt;/code> returns an image.&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-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">curl -o qr.png &amp;#34;https://api.qrserver.com/v1/create-qr-code/?size=150x150&amp;amp;data=HelloWorld&amp;#34;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>Output result
&lt;img src="http://kenji.blog/p/curl%E3%81%A7qr%E3%82%B3%E3%83%BC%E3%83%89%E7%94%9F%E6%88%90/qr.png"
width="250"
height="250"
srcset="http://kenji.blog/p/curl%E3%81%A7qr%E3%82%B3%E3%83%BC%E3%83%89%E7%94%9F%E6%88%90/qr_hud34111b99823e39dfc62f9ba667fd5f9_390_480x0_resize_box_3.png 480w, http://kenji.blog/p/curl%E3%81%A7qr%E3%82%B3%E3%83%BC%E3%83%89%E7%94%9F%E6%88%90/qr_hud34111b99823e39dfc62f9ba667fd5f9_390_1024x0_resize_box_3.png 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="100"
data-flex-basis="240px"
>&lt;/li>
&lt;/ul>
&lt;h4 id="reference-1">Reference
&lt;/h4>&lt;ul>
&lt;li>&lt;a class="link" href="https://goqr.me/api/doc/create-qr-code/" target="_blank" rel="noopener"
>QR Code Generator&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>