LinuxCommandLibrary

conan

Manage C and C++ package dependencies

TLDR

Install packages based on conanfile.txt

$ conan install [.]
copy

Install packages and create configuration files for a specific generator
$ conan install -g [generator]
copy

Install packages, building from source
$ conan install [.] --build
copy

Search for locally installed packages
$ conan search [package]
copy

Search for remote packages
$ conan search [package] -r [remote]
copy

List remotes
$ conan remote list
copy

SYNOPSIS

conan <command> [<options>] [<arguments>]

PARAMETERS

install
    Installs dependencies for a recipe or package reference

create
    Builds and exports a package, deprecated in Conan 2.x in favor of install

search
    Searches packages in remote repositories

info
    Displays dependency graph and build info

profile
    Manages build profiles (detect, new, edit)

export
    Exports a conanfile to the cache

download
    Downloads a package recipe or binary

-h, --help
    Shows help for command or subcommand

--version
    Displays Conan version

-v, --verbose
    Increases verbosity level

--profile=PROFILE
    Uses specified build profile

--build=MODE
    Controls build mode (missing, outdated, etc.)

DESCRIPTION

Conan is an open-source, decentralized package manager specifically designed for C and C++ projects. It simplifies dependency management across different platforms, compilers, and build systems by allowing developers to declare dependencies in a conanfile.py or conanfile.txt. Conan fetches binaries from remote repositories like ConanCenter or Artifactory, builds from source if needed, and generates necessary files for tools like CMake, Meson, or Autotools.

It supports cross-compilation, profiles for different environments (e.g., Windows x86_64 GCC), and versioning with semantic constraints. Conan creates a local cache of packages, ensuring reproducible builds. Key features include binary reuse to speed up CI/CD, editable packages for local development, and integration with CI systems. Unlike traditional managers, it's language-agnostic for consumers but excels in C/C++ ecosystems, handling complex transitive dependencies effortlessly.

CAVEATS

Requires Python 3.7+; Conan 2.x has breaking changes from 1.x (e.g., no 'conan create'). Not in standard distros; install via pip. Large cache can consume significant disk space.

CONFIGURATION

Uses ~/.conan/global.conf and ~/.conan/conan.conf for remotes, hooks, and settings.
Example: conan remote add conancenter https://center.conan.io

BASIC USAGE

conan profile detect to auto-configure.
conan install . --build=missing to install deps and build if needed.

HISTORY

Developed by JFrog starting 2015-2016 as response to C/C++ dependency hell. Conan 1.x released 2018, gained popularity with ConanCenter repo. Acquired by JFrog 2021. Conan 2.0 (2023) refactored for better performance, modularity, and Python-free CLI.

SEE ALSO

pip(1), apt(8), pkg-config(1), cmake(1)

Copied to clipboard