快速开始 - Windows
首先,下载vcpkg,它可以安装在任何地方,但是通常我们建议您使用 vcpkg 作为 CMake 项目的子模块,并将其全局安装到 Visual Studio 项目中。我们建议您使用如 D:\src\vcpkg 或 D:\dev\vcpkg 的安装目录,否则在安装某些库时,您可能遇到路径问题或权限问题。
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS D:\> git clone https://github.com/microsoft/vcpkg.git
Cloning into 'vcpkg'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 104557 (delta 2), reused 4 (delta 1), pack-reused 104543
Receiving objects: 100% (104557/104557), 31.73 MiB | 32.10 MiB/s, done.
Resolving deltas: 100% (65552/65552), done.
Updating files: 100% (7280/7280), done.
PS D:\>
进入克隆的vcpkg目录中, 请使用powershell执行bootstrap-vcpkg.bat脚本下载已签名的vcpkg二进制文件。
注意:使用cmd命令行,Visual Studio命令行或其他命令行执行vcpkg命令可能导致编译过程中脚本调用错误或其他问题,所以我们推荐使用powershell。
PS D:\vcpkg> .\bootstrap-vcpkg.bat
Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2021-02-24-d67989bce1043b98092ac45996a8230a059a2d7e/vcpkg.exe -> D:\vcpkg/vcpkg.exe
Done.
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
PS D:\vcpkg>
若不想让vcpkg上传遥测数据(仅用于改善vcpkg),请在bootstrap-vcpkg.bat脚本后添加命令-disableMetrics。
至此,我们已经准备好安装vcpkg支持的第三方库了。对于一些编译过程中需要的工具,则会在首次安装库时自动下载。
示例:安装zlib
.\vcpkg.exe install zlib
输出信息:
PS D:\vcpkg> .\vcpkg.exe install zlib
Computing installation plan...
A suitable version of cmake was not found (required v3.19.2). Downloading portable cmake v3.19.2...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2-win32-x86.zip -> D:\vcpkg\downloads\cmake-3.19.2-win32-x86.zip
Extracting cmake...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Downloading 7zip...
https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> D:\vcpkg\downloads\7-zip.commandline.18.1.0.nupkg
Extracting 7zip...
A suitable version of nuget was not found (required v5.5.1). Downloading portable nuget v5.5.1...
Downloading nuget...
https://dist.nuget.org/win-x86-commandline/v5.5.1/nuget.exe -> D:\vcpkg\downloads\22ea847d-nuget.exe
The following packages will be built and installed:
zlib[core]:x86-windows -> 1.2.11#9
Detecting compiler hash for triplet x86-windows...
A suitable version of git was not found (required v2.26.2). Downloading portable git v2.26.2...
Downloading git...
https://github.com/git-for-windows/git/releases/download/v2.26.2.windows.1/PortableGit-2.26.2-32-bit.7z.exe -> D:\vcpkg\downloads\PortableGit-2.26.2-32-bit.7z.exe
Extracting git...
A suitable version of powershell-core was not found (required v7.1.0). Downloading portable powershell-core v7.1.0...
Downloading powershell-core...
https://github.com/PowerShell/PowerShell/releases/download/v7.1.0/PowerShell-7.1.0-win-x86.zip -> D:\vcpkg\downloads\PowerShell-7.1.0-win-x86.zip
Extracting powershell-core...
Using cached binary package: C:\Users\jack\AppData\Local\vcpkg\archives\36\361ee62e74ca723768c8504c31a2a806c00294fa.zip
Starting package 1/1: zlib:x86-windows
Building package zlib[core]:x86-windows...
Building package zlib[core]:x86-windows... done
Installing package zlib[core]:x86-windows...
Installing package zlib[core]:x86-windows... done
Elapsed time for package zlib:x86-windows: 135.9 ms
Total elapsed time: 20.34 s
The package zlib is compatible with built-in CMake targets:
find_package(ZLIB REQUIRED)
target_link_libraries(main PRIVATE ZLIB::ZLIB)
PS D:\vcpkg>
VCPKG 团队期待您的贡献!

浙公网安备 33010602011771号