Vcpkg 是由 Microsoft 和 C++ 社区维护的免费开源 C/C++ 包管理器,可在 Windows、macOS 和 Linux 上运行。 它是核心的 C++ 工具,使用 C++ 和 CMake 脚本编写。 它旨在解决管理 C/C++ 库的独特难题。

安装

克隆 vcpkg 仓库

POWERSHELL
git clone https://github.com/microsoft/vcpkg.git

初始化 vcpkg

POWERSHELL
.\bootstrap-vcpkg.bat

配置

配置环境变量(设置 VCPKG_ROOT 和 PATH)

POWERSHELL
$env:VCPKG_ROOT="C:\path\to\vcpkg"
$env:PATH="$env:VCPKG_ROOT;$env:PATH"

(可选,建议)全局集成 vcpkg,可让Visual Studio、CMake 自动识别 vcpkg 管理的依赖,无需手动指定库路径,但需先安装Visual Studio(需勾选“C++桌面开发”组件)

POWERSHELL
vcpkg integrate install

使用

安装库

POWERSHELL
vcpkg

列出已安装

POWERSHELL

: Cheyne Xie

: https://chaim.eu.org/posts/2a09cb8b/

: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.