In vcpkg, what does a triplet such as x64-windows or arm64-osx define, and which triplet is used when none is given?
answer
- a named CMake file of settings
- architecture, system, two linkages
- target triplet and host triplet
- processor plus OS of the machine
basics
~20 sA triplet is a named CMake file that sets the target architecture, system and library and CRT linkage for every port built with it. Without --triplet or VCPKG_DEFAULT_TRIPLET, vcpkg targets the host triplet detected from the machine, such as arm64-osx on arm64 Macs.
solid answer
~40 sA **triplet** captures a whole target configuration in one name. In vcpkg it is a file, `<name>.cmake` in the `triplets` directory, that sets variables such as `VCPKG_TARGET_ARCHITECTURE`, `VCPKG_CMAKE_SYSTEM_NAME` (empty means Windows desktop), `VCPKG_LIBRARY_LINKAGE` and `VCPKG_CRT_LINKAGE`. The built-in defaults differ by platform: `x64-windows` builds DLLs with the dynamic CRT, while `x64-linux` and `arm64-osx` build static libraries. Each install lands under a per-triplet subdirectory, and a build uses up to two triplets: the **target** triplet for the libraries you link and the **host** triplet for tools that run during the build (`"host": true` dependencies). The command line picks `--triplet`, then the `VCPKG_DEFAULT_TRIPLET` environment variable, then the host triplet, which vcpkg-tool derives from the machine's processor and OS. In the 2026.10.16 registry, `x64-osx` lives among the community triplets.
go deeper
Recall that a triplet names architecture, platform and linkage, and name a few built-in ones such as x64-windows, x64-linux and arm64-osx.
Explain what the triplet file sets, the static default on Linux and macOS versus DLLs on Windows, and how the default triplet is chosen.
Show you know the host versus target split for tools, that the triplet file feeds the ABI hash, and that ports can override the preferred linkage.
Decide which triplets the team supports and tests, since every extra triplet multiplies build time and cache storage.
## What a triplet is "Triplet" is a cross-compiling term for a name that pins down a target environment: CPU, OS, runtime. In vcpkg a triplet is concretely a **CMake script** named after the triplet, such as `triplets/x64-windows.cmake`, that vcpkg includes before building each port. The port's build reads the variables it sets. Triplet names may contain only lowercase letters, digits and hyphens, and the file name is the triplet name plus `.cmake`. The core variables are: - `VCPKG_TARGET_ARCHITECTURE`: `x86`, `x64`, `arm`, `arm64`, `arm64ec`, `wasm32` and others; - `VCPKG_CMAKE_SYSTEM_NAME`: the target platform (`Linux`, `Darwin`, `Android`, `MinGW`, `WindowsStore`), with **empty meaning Windows desktop** for historical reasons; - `VCPKG_LIBRARY_LINKAGE`: `static` or `dynamic`, the preferred kind of library; - `VCPKG_CRT_LINKAGE`: `static` or `dynamic`, the MSVC runtime linkage. Optional variables add a release-only build (`VCPKG_BUILD_TYPE release`), extra flags, a chain-loaded toolchain or macOS deployment settings. ## The built-in triplets In the 2026.10.16 registry the top-level `triplets` directory holds the tested triplets, while `triplets/community` holds ones the curated registry's CI does not test (vcpkg prints a notice when it loads one). | Triplet | Libraries | CRT | Notes | |---|---|---|---| | `x64-windows` | dynamic (DLLs) | dynamic | Windows default on x64 | | `x64-windows-static` | static | static (`/MT`) | no runtime DLLs at all | | `x64-windows-static-md` | static | dynamic | static libraries, shared CRT | | `x64-linux` | static | dynamic | Linux default on x64 | | `arm64-osx` | static | dynamic | arm64 macOS default | | `x64-osx` | static | dynamic | a community triplet at this release | Note the asymmetry: the Windows default builds DLLs, while the Linux and macOS defaults build static libraries. Dynamic variants for Linux and macOS, such as `x64-linux-dynamic`, are community triplets. ## Target and host triplets A single build consumes files from up to two triplets: - the **target triplet**, whose libraries and headers your program links against; - the **host triplet**, used for dependencies marked `"host": true`, the build tools (code generators, `vcpkg-cmake` helpers) that must run on the build machine. When they differ, as when cross-compiling for `arm64-android` on an x64 Linux host, this split is what lets tools run while libraries target the device. The installed tree has one subdirectory per triplet, for example `vcpkg_installed/x64-linux/include` and `vcpkg_installed/x64-linux/lib`. ## Which triplet is used by default On the command line, vcpkg-tool resolves the target triplet in this order: 1. `--triplet=<name>`, or in classic mode a qualified name such as `zlib:x64-windows-static`; 2. the `VCPKG_DEFAULT_TRIPLET` environment variable; 3. the **host triplet**: `--host-triplet`, then `VCPKG_DEFAULT_HOST_TRIPLET`, then a name built from the detected host processor and OS. So an x64 Windows machine targets `x64-windows`, an x64 Linux machine `x64-linux`, and an arm64 Mac `arm64-osx`. Older docs list `x64-osx` as the macOS default; the tool derives the name from the processor, so that is true only on x64 Macs. Build-system integrations choose their own default from the compiler settings; that logic belongs to the CMake integration material. ## Why the triplet matters in practice - Each triplet is a separate universe of binaries: changing it rebuilds everything, and the triplet file's contents are part of every package's ABI hash. - Platform expressions in manifests (`windows`, `osx`, `static`, `staticcrt`) are evaluated against the triplet's variables. - A port may ignore the preferred linkage when it cannot honour it, so a static triplet does not guarantee every package is static. ## Reading a triplet you were handed When a build behaves unexpectedly, open the triplet file before anything else; it is short and decisive. A practical reading order: 1. **Which file was loaded?** vcpkg prints the triplet path it loads, and a community triplet produces an extra notice. An overlay directory can shadow a built-in name, so the path matters as much as the name. 2. **Architecture and system**: `VCPKG_TARGET_ARCHITECTURE` and `VCPKG_CMAKE_SYSTEM_NAME` tell you what the binaries run on; an empty system name on Windows is normal. 3. **Linkage pair**: `VCPKG_LIBRARY_LINKAGE` and `VCPKG_CRT_LINKAGE` explain most "why is there a DLL here" and "why will this not link" questions. 4. **Extras**: `VCPKG_BUILD_TYPE`, extra flags or a chain-loaded toolchain explain differences between two machines that use "the same" triplet name. The same reading applies to the host triplet when a build tool, rather than a library, misbehaves.
- Why does a Linux build with vcpkg's default triplet produce no .so files for the dependencies?The built-in `x64-linux` triplet sets `VCPKG_LIBRARY_LINKAGE` to `static`, as `arm64-osx` does on macOS, so libraries are built as archives. For shared libraries use a dynamic triplet such as the community `x64-linux-dynamic`, or a custom triplet with `VCPKG_LIBRARY_LINKAGE dynamic`.
- What is the host triplet used for?It builds dependencies marked `"host": true`, tools that execute during the build such as code generators and the `vcpkg-cmake` helper ports. Keeping them on the host triplet lets cross-compilation work when the target's binaries cannot run on the build machine.
- A triplet is just a label; vcpkg ignores everything after the architecture.
- Every built-in triplet builds shared libraries by default, including on Linux.
- vcpkg always defaults to x64-osx on any Mac.
- Host and target triplet are the same thing under two names.
- VCPKG_CMAKE_SYSTEM_NAME must be set to Windows for Windows desktop triplets.
Assumes vcpkg 2026.10.16 with vcpkg-tool 2026-09-26: x64-osx is a community triplet there, and the CLI defaults to the host triplet detected from processor and OS.