CppPilot

Practical guide Visual Studio C++

Use vcpkg libraries in Visual Studio

vcpkg downloads and builds C++ libraries, and its MSBuild integration adds their include directories, libraries, and DLLs to your project. In manifest mode, the libraries are listed in a vcpkg.json file next to the project.

Applies toVisual Studio MSBuild C++ projects (.vcxproj)
ExamplesFocused excerpts; required context is stated alongside each example

Visual Studio property-page paths describe MSBuild projects. For CMake, configure the corresponding target or preset. Menu names can vary by Visual Studio version; use the cited reference for your toolset.

How it worksFrom a dependency to a linked program
  1. vcpkg.jsonDeclare dependencies
  2. TripletChoose architecture + runtime
  3. MSBuildRestore, compile, and link

The manifest names the libraries; the triplet selects their architecture and runtime; MSBuild integrates the resulting files.

Install and integrate vcpkg

vcpkg is a component of the Desktop development with C++ workload in Visual Studio 2022 17.6 and later, available in the Developer PowerShell. You can also clone it from GitHub and run bootstrap-vcpkg.bat. Then run vcpkg integrate install once, so that MSBuild projects can use it.

Add a library

  1. In the Developer PowerShell, in the project folder, run vcpkg new --application. It creates vcpkg.json and vcpkg-configuration.json.
  2. Add the libraries: vcpkg add port fmt.
  3. In the project properties, set vcpkg > Use Vcpkg Manifest to Yes.
  4. Build: vcpkg builds the libraries the first time, then Visual Studio finds their headers and links them.

vcpkg.json — declare the library

{  "dependencies": [    "fmt"  ]}

main.cpp — use it

#include <fmt/core.h>int main() {    fmt::print("Hello from C++\n");}
ExampleEnable Use Vcpkg Manifest for the project and configuration. The manifest declares the dependency; integration supplies its headers and library.

Choose the triplet

The triplet decides how the libraries are built. It must match the runtime library of your project, or the link fails with LNK2038 or LNK4098:

  • x64-windows: DLLs, with the dynamic runtime (/MD), the default. vcpkg copies the DLLs next to your program.
  • x64-windows-static: static libraries with the static runtime (/MT).
  • x64-windows-static-md: static libraries with the dynamic runtime (/MD).

Set it in vcpkg > Triplet, or with Use Static Libraries, for each platform.

CompatibilityMatch the library build to the project
TripletLibrary linkageRelease runtime
x64-windowsDynamic/MD
x64-windows-staticStatic/MT
x64-windows-static-mdStatic/MD

Debug builds use the corresponding /MDd or /MTd runtime. Match architecture and configuration as well.

Fix the usual errors

  • C1083 cannot open include file: the manifest is not enabled for this configuration, or the library is not in vcpkg.json.
  • LNK2019: the library is installed for another platform or triplet, or the project was not integrated. Check the vcpkg section of the Build output.
  • LNK2038 on RuntimeLibrary: the triplet does not match Runtime Library.

Sources and scope

Official references

These links document the compiler, build system, or debugger behavior discussed here. Use the version selector on Microsoft Learn for your toolset. Example blocks are focused excerpts; required headers and build settings are stated alongside them.

Using CppPilot in Visual Studio

CppPilot connects your own Codex or Claude account to Visual Studio. If you have neither, CppPilot Cloud provides AI access for build fixes, reviews, crash analysis, and project checks. AI chat requires your own Codex or Claude account.

Setup instructions · Visual Studio Marketplace