TExcelTAD
Home › C/C++ Packages: Conan 2, vcpkg & CPM.cmake › Package IDs & Binary Compatibility

Package IDs & Binary Compatibility

One recipe, fmt/12.1.0, can have dozens of binaries: Linux and Windows, Debug and Release, static and shared, GCC and MSVC. Conan tells them apart with the package ID, a SHA-1 hash of the binary's configuration. Understanding what goes into that hash explains every "missing binary" error and every unexpected rebuild.

The full reference

text
spdlog/1.17.0#bcbaaf7147bda6ad24ffbd1ac3d7142c:68cf2b888a31d527b3476ac5bf6707b2db1ccd2d#81ce70d6997cc1fbe7ed27c13c7c4bac
└─name/version┘└──── recipe revision ────────┘ └──────────── package ID ──────────────┘└─── package revision ────────┘
Part Identifies Changes when
name/version the library release you require another version
recipe revision (RREV) the exact recipe + exported sources the recipe or its patches change
package ID one binary configuration settings, options or relevant dependency versions change
package revision (PREV) one build of that configuration the same configuration is rebuilt and uploaded again

What goes into the ID: conaninfo.txt

Every binary in the cache carries a conaninfo.txt, the text that was hashed into its package ID:

bash · try it yourself
cat "$(conan cache path spdlog/1.17.0:68cf2b888a31d527b3476ac5bf6707b2db1ccd2d)/conaninfo.txt"
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=13
os=Linux
[options]
fPIC=True
header_only=False
no_exceptions=False
shared=False
use_std_fmt=False
[requires]
fmt/12.1.Z

Three sections: the settings the recipe declares, its options, and its requires, written as fmt/12.1.Z. That last line is a policy, not a mistake: by default a static library's ID depends on the major.minor version of its dependencies (the "minor mode" for non-embedding requirements), so a new fmt patch release doesn't force spdlog binaries to be rebuilt, but fmt 12.2 does. Shared libraries and executables that embed a static dependency use a stricter mode that includes the full version and revision, because the dependency's code is copied into them.

Watching IDs change

To see binaries multiply, create a small package of our own (Conan's cmake_lib template, explained in the next section) in two build types:

bash · try it yourself
mkdir -p greet && cd greet
conan new cmake_lib -d name=greet -d version=1.0.0 > /dev/null 2>&1
conan create . -c tools.build:jobs=1 2>&1 | grep -E "^greet/1.0.0: Package '"
conan create . -s build_type=Debug -c tools.build:jobs=1 2>&1 | grep -E "^greet/1.0.0: Package '"
conan list "greet/1.0.0:*" --format=compact 2>&1 | sed -n '3,$p' | sed 's/%[0-9.]* (.*)//'
greet/1.0.0: Package '838c313f1b7acdfd23b222f0156e7c264dcc2515' built
greet/1.0.0: Package 'c5487c246d32d1a5390c207a5d0554eb06944ca9' built
    greet/1.0.0#985a47244e0721362a6bfde1360bb9d4
      greet/1.0.0#985a47244e0721362a6bfde1360bb9d4:838c313f1b7acdfd23b222f0156e7c264dcc2515
        settings: Linux, x86_64, Release, gcc, gnu17, libstdc++11, 13
        options: fPIC=True, shared=False
      greet/1.0.0#985a47244e0721362a6bfde1360bb9d4:c5487c246d32d1a5390c207a5d0554eb06944ca9
        settings: Linux, x86_64, Debug, gcc, gnu17, libstdc++11, 13
        options: fPIC=True, shared=False

(The last sed strips the recipe's creation timestamp, which changes on every run.) Same recipe revision, two package IDs that differ only in build_type. A third conan create with the same settings would reuse the existing package ID (and, if rebuilt, produce a new package revision under it).

Binary compatibility

An exact ID match isn't always necessary. A library compiled as C++17 links fine into a C++20 program, and a binary made with GCC 13.2 works with GCC 13.3. Conan handles this with compatibility: when the exact binary is missing, it computes the IDs of compatible configurations and tries those. The default compatibility.py plugin (in ~/.conan2/extensions/plugins/compatibility/) falls back across compiler.cppstd values, and on Windows across MSVC update versions. You saw it work in Profiles & conf. When it fails, conan graph explain tells you the closest binary and what differs:

bash · try it yourself
conan graph explain --requires=fmt/12.1.0 -s build_type=Debug -nr 2>&1 | sed -n '/Closest binaries/,$p'
======== Closest binaries ========
fmt/12.1.0
  fmt/12.1.0#6baf0fb8351783472b94ee6e36232391%1785754553.994 (2026-08-03 10:55:53 UTC)
    fmt/12.1.0#6baf0fb8351783472b94ee6e36232391:e02956bd268869d4519cb2b90dc7b4e51911a5d0
      remote: Local Cache
      settings: Linux, x86_64, Release, gcc, gnu17, libstdc++11, 13
      options(diff):
      diff
        settings
          expected: build_type=Debug
          existing: build_type=Release
        explanation: This binary was built with different settings.

Controlling the ID in a recipe

Recipes adjust their own package ID in package_id() and the package_type attribute:

python
class ToolRecipe(ConanFile):
    package_type = "application"
    settings = "os", "arch", "compiler", "build_type"

    def package_id(self):
        # A command-line tool: consumers only care that it runs here
        del self.info.settings.compiler
        del self.info.settings.build_type

class HeaderOnly(ConanFile):
    package_type = "header-library"
    def package_id(self):
        self.info.clear()            # one binary for every configuration

class MyLib(ConanFile):
    def compatibility(self):         # extra fallbacks just for this recipe
        return [{"settings": [("build_type", "Release")]}]   # accept a Release build for RelWithDebInfo

Other tools: self.info.requires.full_mode() for a stricter dependency policy, core.package_id:default_non_embed_mode and friends in global.conf to change the default for everything.

A runnable model: compatibility fallbacks

This model computes an ID from a configuration and, when that binary is missing, tries the cppstd fallbacks in order, like the plugin:

python · try it yourself
import hashlib

def pid(cfg):
    text = "\n".join(f"{k}={v}" for k, v in sorted(cfg.items()))
    return hashlib.sha1(text.encode()).hexdigest()[:8]

base = {"os": "Linux", "arch": "x86_64", "compiler": "gcc", "compiler.version": "13",
        "build_type": "Release", "compiler.cppstd": "gnu17"}
cache = {pid(base)}                        # only the gnu17 Release binary exists

def find(cfg, fallbacks=("17", "gnu17", "20", "gnu20")):
    wanted = pid(cfg)
    if wanted in cache:
        return f"{wanted} exact"
    for std in fallbacks:
        alt = dict(cfg, **{"compiler.cppstd": std})
        if pid(alt) in cache:
            return f"{wanted} missing -> compatible {pid(alt)} (cppstd={std})"
    return f"{wanted} missing, no compatible binary"

print("gnu17 Release:", find(base))
print("20 Release:   ", find(dict(base, **{"compiler.cppstd": "20"})))
print("gnu17 Debug:  ", find(dict(base, build_type="Debug")))
gnu17 Release: 57e391e8 exact
20 Release:    4fec7846 missing -> compatible 57e391e8 (cppstd=gnu17)
gnu17 Debug:   3f688661 missing, no compatible binary

Test yourself

Which part of a reference changes when you build fmt in Debug instead of Release?

  1. The recipe revision
  2. The package ID
  3. The version
  4. Nothing

spdlog's conaninfo.txt lists fmt/12.1.Z. What does that mean?

  1. spdlog works with any fmt
  2. spdlog's package ID depends on fmt's major.minor, so fmt 12.1.x patch releases don't require new spdlog binaries
  3. A typo
  4. fmt is optional

What does self.info.clear() in package_id() achieve for a header-only library?

  1. Deletes the package
  2. Every configuration gets the same package ID, so one binary serves everyone
  3. Speeds up compilation
  4. Removes the headers