仮想計算機構

IT業界と無縁な派遣社員のブログ

【自分用メモ】vcpkgを使ってcurlをインストールする

下記を参考にcurlをインストールします。あくまで自分用のメモです。
curl/docs/INSTALL.md at master · curl/curl · GitHub

0.環境

OS : Windows 10
端末 : Windows Terminal ( PowerShell )

1.vcpkg のインストール

> git clone https://github.com/Microsoft/vcpkg.git
Cloning into 'vcpkg'...
remote: Enumerating objects: 203084, done.
remote: Counting objects: 100% (17648/17648), done.
remote: Compressing objects: 100% (1191/1191), done.
remote: Total 203084 (delta 16755), reused 16585 (delta 16457), pack-reused 185436
Receiving objects: 100% (203084/203084), 62.00 MiB | 4.07 MiB/s, done.
Resolving deltas: 100% (135407/135407), done.
Updating files: 100% (10485/10485), done.
cd vcpkg
vcpkg > .\bootstrap-vcpkg.bat
Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2023-08-09/vcpkg.exe -> C:\Users\user\Desktop\MyProgram\vcpkg\vcpkg.exe... done.
Validating signature... done.

vcpkg package management program version 2023-08-09-9990a4c9026811a312cb2af78bf77f3d9d288416

See LICENSE.txt for license information.
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md
vcpkg > .\vcpkg.exe integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/Users/user/Desktop/MyProgram/vcpkg/scripts/buildsystems/vcpkg.cmake"

All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.

2.curl をインストールする

vcpkg> .\vcpkg.exe install curl[tool]
warning: Starting with the September 2023 release, the default triplet for vcpkg libraries will change from x86-windows to the detected host triplet (x64-windows). To resolve this message, add --triplet x86-windows to keep the same behavior.
Computing installation plan...
A suitable version of cmake was not found (required v3.27.1) Downloading portable cmake 3.27.1...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-windows-i386.zip->C:\Users\user\Desktop\MyProgram\vcpkg\downloads\cmake-3.27.1-windows-i386.zip
Downloading https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-windows-i386.zip
Extracting cmake...
The following packages will be built and installed:
    curl[core,non-http,schannel,ssl,sspi,tool]:x86-windows -> 8.2.1
  * vcpkg-cmake:x64-windows -> 2023-05-04
  * vcpkg-cmake-config:x64-windows -> 2022-02-06#1
  * zlib:x86-windows -> 1.2.13
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
A suitable version of powershell-core was not found (required v7.2.11) Downloading portable powershell-core 7.2.11...
Downloading powershell-core...
https://github.com/PowerShell/PowerShell/releases/download/v7.2.11/PowerShell-7.2.11-win-x86.zip->C:\Users\user\Desktop\MyProgram\vcpkg\downloads\PowerShell-7.2.11-win-x86.zip
Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.2.11/PowerShell-7.2.11-win-x86.zip
Extracting powershell-core...
Detecting compiler hash for triplet x86-windows...
A suitable version of 7zip was not found (required v21.7.0) Downloading portable 7zip 21.7.0...
Downloading 7zip...
https://www.7-zip.org/a/7z2107-extra.7z->C:\Users\user\Desktop\MyProgram\vcpkg\downloads\7z2107-extra.7z
Downloading https://www.7-zip.org/a/7z2107-extra.7z
Extracting 7zip...
Restored 0 package(s) from C:\Users\user\AppData\Local\vcpkg\archives in 1.09 ms. Use --debug to see more details.
Installing 1/4 vcpkg-cmake:x64-windows...
Building vcpkg-cmake:x64-windows...
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg-port-config.cmake
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 220 ms.
Elapsed time to handle vcpkg-cmake:x64-windows: 1.2 s
Installing 2/4 vcpkg-cmake-config:x64-windows...
Building vcpkg-cmake-config:x64-windows...
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/vcpkg-port-config.cmake
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 52.8 ms.
Elapsed time to handle vcpkg-cmake-config:x64-windows: 237 ms
Installing 3/4 zlib:x86-windows...
Building zlib:x86-windows...
-- Downloading https://github.com/madler/zlib/archive/v1.2.13.tar.gz -> madler-zlib-v1.2.13.tar.gz...
-- Extracting source C:/Users/user/Desktop/MyProgram/vcpkg/downloads/madler-zlib-v1.2.13.tar.gz
-- Applying patch 0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch
-- Applying patch 0002-skip-building-examples.patch
-- Applying patch 0003-build-static-or-shared-not-both.patch
-- Applying patch 0004-android-and-mingw-fixes.patch
-- Using source at C:/Users/user/Desktop/MyProgram/vcpkg/buildtrees/zlib/src/v1.2.13-f30d2a168d.clean
-- Configuring x86-windows
-- Building x86-windows-dbg
-- Building x86-windows-rel
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/zlib_x86-windows/share/zlib/vcpkg-cmake-wrapper.cmake
-- Fixing pkgconfig file: C:/Users/user/Desktop/MyProgram/vcpkg/packages/zlib_x86-windows/lib/pkgconfig/zlib.pc
-- Downloading https://mirror.msys2.org/mingw/mingw32/mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst;https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst;https://mirror.yandex.ru/mirrors/msys2/mingw/mingw32/mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst;https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/mingw32/mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst;https://mirrors.ustc.edu.cn/msys2/mingw/mingw32/mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst;https://mirror.selfnet.de/msys2/mingw/mingw32/mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst -> mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst...
-- Downloading https://mirror.msys2.org/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst;https://repo.msys2.org/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst;https://mirror.yandex.ru/mirrors/msys2/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst;https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst;https://mirrors.ustc.edu.cn/msys2/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst;https://mirror.selfnet.de/msys2/msys/x86_64/msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst -> msys2-msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst...
-- Using msys root at C:/Users/user/Desktop/MyProgram/vcpkg/downloads/tools/msys2/6f3fa1a12ef85a6f
-- Fixing pkgconfig file: C:/Users/user/Desktop/MyProgram/vcpkg/packages/zlib_x86-windows/debug/lib/pkgconfig/zlib.pc
CMake Warning at scripts/cmake/vcpkg_copy_pdbs.cmake:44 (message):
  Could not find a matching pdb file for:

      C:/Users/user/Desktop/MyProgram/vcpkg/packages/zlib_x86-windows/bin/zlib1.dll
      C:/Users/user/Desktop/MyProgram/vcpkg/packages/zlib_x86-windows/debug/bin/zlibd1.dll

Call Stack (most recent call first):
  ports/zlib/portfile.cmake:44 (vcpkg_copy_pdbs)
  scripts/ports.cmake:147 (include)


-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/zlib_x86-windows/share/zlib/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 129 ms.
Elapsed time to handle zlib:x86-windows: 36 s
Installing 4/4 curl:x86-windows...
Building curl[core,non-http,schannel,ssl,sspi,tool]:x86-windows...
-- Downloading https://github.com/curl/curl/archive/curl-8_2_1.tar.gz -> curl-curl-curl-8_2_1.tar.gz...
-- Extracting source C:/Users/user/Desktop/MyProgram/vcpkg/downloads/curl-curl-curl-8_2_1.tar.gz
-- Applying patch 0002_fix_uwp.patch
-- Applying patch 0005_remove_imp_suffix.patch
-- Applying patch 0012-fix-dependency-idn2.patch
-- Applying patch 0020-fix-pc-file.patch
-- Applying patch 0022-deduplicate-libs.patch
-- Applying patch mbedtls-ws2_32.patch
-- Applying patch export-components.patch
-- Applying patch dependencies.patch
-- Using source at C:/Users/user/Desktop/MyProgram/vcpkg/buildtrees/curl/src/curl-8_2_1-1a1f01a28f.clean
-- Configuring x86-windows
-- Building x86-windows-dbg
-- Building x86-windows-rel
CMake Warning at scripts/cmake/vcpkg_copy_pdbs.cmake:44 (message):
  Could not find a matching pdb file for:

      C:/Users/user/Desktop/MyProgram/vcpkg/packages/curl_x86-windows/bin/libcurl.dll
      C:/Users/user/Desktop/MyProgram/vcpkg/packages/curl_x86-windows/debug/bin/libcurl-d.dll

Call Stack (most recent call first):
  ports/curl/portfile.cmake:81 (vcpkg_copy_pdbs)
  scripts/ports.cmake:147 (include)


-- Fixing pkgconfig file: C:/Users/user/Desktop/MyProgram/vcpkg/packages/curl_x86-windows/lib/pkgconfig/libcurl.pc
-- Using cached mingw-w64-i686-pkgconf-1~1.8.0-2-any.pkg.tar.zst.
-- Using cached msys2-msys2-runtime-3.4.6-1-x86_64.pkg.tar.zst.
-- Using msys root at C:/Users/user/Desktop/MyProgram/vcpkg/downloads/tools/msys2/6f3fa1a12ef85a6f
-- Fixing pkgconfig file: C:/Users/user/Desktop/MyProgram/vcpkg/packages/curl_x86-windows/debug/lib/pkgconfig/libcurl.pc
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/curl_x86-windows/share/curl/vcpkg-cmake-wrapper.cmake
-- Installing: C:/Users/user/Desktop/MyProgram/vcpkg/packages/curl_x86-windows/share/curl/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 538 ms.
Elapsed time to handle curl:x86-windows: 4 min
Total install time: 4.6 min
curl provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(CURL CONFIG REQUIRED)
    target_link_libraries(main PRIVATE CURL::libcurl)

3.curl を使ってみる

> curl https://ja.wikipedia.org
StatusCode        : 200
StatusDescription : OK
Content           : <!DOCTYPE html>
                    <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-
                    page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-...
(以下略)