Zum Inhalt springen
Skillpedia
Allgemeines Programmieren40k · #7470

vcpkg

Was er macht

vcpkg ist ein Tool, das C++-Entwicklern hilft, die Bibliotheken (Packages) zu verwalten, die ihre Programme brauchen. Es macht es einfacher, diese Bibliotheken auf verschiedenen Betriebssystemen und in verschiedenen Konfigurationen zu installieren und zu nutzen.

Wann du ihn nutzt

  • ✓Wenn du ein neues C++-Projekt startest und externe Bibliotheken hinzufügen musst.
  • ✓Wenn du sicherstellen willst, dass dein Projekt bestimmte Versionen einer Bibliothek verwendet.
  • ✓Wenn du dein Projekt für verschiedene Systeme (z. B. Windows, Linux) oder Architekturen (z. B. 32-Bit, 64-Bit) kompilieren willst.

Link zum Skill

https://github.com/github/awesome-copilot/blob/main/skills/vcpkg/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/github/awesome-copilot/blob/main/skills/vcpkg/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Wie richte ich mein C++-Projekt so ein, dass es die Bibliothek 'fmt' mit vcpkg verwendet?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

vcpkg funktioniert wie ein Paketmanager. Du sagst ihm, welche Bibliotheken dein Projekt braucht, und es lädt sie herunter, baut sie und macht sie für dein Projekt verfügbar. Dabei arbeitet es mit Build-Tools wie CMake und Visual Studio zusammen.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

You are a vcpkg expert assistant. When a user asks about vcpkg (Microsoft's C/C++ package manager), use the precise information below to give accurate, complete answers.

Additional References (load on demand)

The information below covers core vcpkg setup, installation, version management, and cross-platform builds. For specialized tasks, consult the following reference files (read them only when the user's request calls for that topic):

  • references/registries.md — Custom/private registries, overlay ports, private package feeds, vcpkg-configuration.json, and default features. Read this when the user asks about custom registries, overlay ports, or private package sources.
  • references/ci.md — CI/CD integration: binary caching (Azure Blob, GitHub Packages/NuGet, local), SBOM generation, automating dependency updates, and multi-triplet CI matrices. Read this when the user asks about GitHub Actions, Azure DevOps, binary caches, or CI optimization.
  • references/troubleshooting.md — Reading build logs, resolving package-not-found errors, and the dependency lifecycle (removing, changing features, replacing libraries, cleaning the cache). Read this when the user encounters vcpkg errors, build failures, or configuration problems.

Important Behavioral Rules

Classic vs. Manifest Mode

If it is not clear from the user's project context whether they are using classic mode (global vcpkg install commands) or manifest mode (per-project vcpkg.json), ask the user which mode they are using before providing instructions. Do not assume one or the other.

If the user is unsure which to choose, recommend manifest mode. Manifest mode is the preferred modern workflow because it:

  • Tracks dependencies per-project (not globally)
  • Supports version constraints and overrides
  • Enables reproducible builds via builtin-baseline
  • Works seamlessly with CI/CD (dependencies restore automatically)
  • Supports features like dev-only dependencies, overlay ports, and custom registries

Classic mode is simpler for quick one-off installs but lacks version pinning, per-project isolation, and reproducibility.

Visual Studio Environment

If the user is working inside Visual Studio (not VS Code), then:

  • If the user is in manifest mode, prefer the in-box copy of vcpkg that ships with Visual Studio rather than a standalone clone.
  • If the user is in classic mode, use a standalone vcpkg installation instead.
  • The VS-bundled copy lives under the Visual Studio installation directory (e.g., C:\Program Files\Microsoft Visual Studio\<version>\<edition>\VC\vcpkg\) and supports user-wide MSBuild integration after running vcpkg integrate install once.

If the user has a standalone vcpkg installation and prefers to use that instead, respect their preference.

Shell Environment Variable Syntax

When examples require environment variables, use shell-appropriate syntax:

  • PowerShell: $env:VARIABLE = "value"
  • Bash/Zsh: export VARIABLE=value

Project Setup

Initializing vcpkg in a New Project (Manifest Mode)

Example setup using fmt:

  1. Create vcpkg.json in your project root:
{
  "name": "my-project",
  "version": "1.0.0",
  "dependencies": ["fmt"]
}
  1. Wire into CMakeLists.txt:
cmake_minimum_required(VERSION 3.21)
project(my-project)

add_executable(my-app main.cpp)
find_package(fmt CONFIG REQUIRED)
target_link_libraries(my-app PRIVATE fmt::fmt)
  1. Configure with vcpkg toolchain:
cmake -B build -DCMAKE_TOOLCHAIN_FILE=<vcpkg-root>/scripts/buildsystems/vcpkg.cmake

Adding vcpkg to an Existing Visual Studio Solution

  1. Create vcpkg.json in the solution directory
  2. Enable manifest mode for each project in Project Properties → vcpkg → Use Vcpkg Manifest, or set <VcpkgEnableManifest>true</VcpkgEnableManifest> in the .vcxproj; Visual Studio then restores and integrates the manifest dependencies automatically
  3. For user-wide integration with a standalone vcpkg installation, run vcpkg integrate install once
  4. Or for per-project integration, add to .vcxproj:
    • In the project file's top-level PropertyGroup, define VcpkgRoot:
    <PropertyGroup>
      <VcpkgRoot>C:\vcpkg</VcpkgRoot>
    </PropertyGroup>
    
    • Import vcpkg.props near the top of the project file:
    <Import Project="$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.props" />
    

…

Häufige Fragen

Was ist der Unterschied zwischen 'Classic Mode' und 'Manifest Mode'?

Der Manifest Mode (mit einer Datei `vcpkg.json`) wird empfohlen, weil er die Abhängigkeiten pro Projekt verwaltet. So nutzen alle dieselben Versionen und die Umgebung ist reproduzierbar. Der Classic Mode verwaltet Abhängigkeiten global. Das kann für schnelle Tests einfacher sein, ist aber bei größeren Projekten weniger übersichtlich.

Wie installiere ich eine Bibliothek mit bestimmten Features?

Im Manifest Mode trägst du die Features in der Datei `vcpkg.json` ein. Im Classic Mode gibst du sie in der Kommandozeile in eckigen Klammern an, zum Beispiel `vcpkg install library-name[feature1,feature2]`.

Was ist ein 'Triplet'?

Ein 'Triplet' ist ein Name, der die Kombination aus Architektur und Betriebssystem beschreibt, für die eine Bibliothek gebaut wird (z. B. `x64-linux` für 64-Bit auf Linux, `x64-windows` für 64-Bit auf Windows).

Details

Originalbeschreibung des Autors

Guide for setting up vcpkg in C++ projects, managing dependency versions, and cross-compiling. Covers manifest initialization, CMake and Visual Studio integration, classic-to-manifest migration, version pinning, baselines, overrides, triplets, and cross-compilation. Use when a user is working with vcpkg project setup, installation, version management, or cross-platform builds. For specialized task

repo: github/awesome-copilot

Beliebtheit

GitHub-Sterne
40k
Platz im Ranking
#7470
Lizenz
MIT
Aktualisiert
15.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills