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

--version
    Show program's version number and exit.

--help, -h
    Show this help message and exit, or show help for a specific subcommand (e.g., conan install --help).

--json
    Output the command's result in JSON format (where applicable).

Subcommand specific options
    Most options are specific to the subcommand being executed (e.g., conan install has options like --build, --require-override; conan create has --test-folder, --build-policy).

DESCRIPTION

Conan is a decentralized, open-source package manager designed specifically for C/C++ projects. It automates the complex process of managing dependencies across various platforms, compilers, and build systems. Unlike traditional system package managers, Conan focuses on developer-centric workflows, allowing the creation, packaging, and consumption of binaries and source code.

Its core purpose is to solve the historical challenges of C/C++ dependency management, including binary compatibility issues, cross-platform development, and integration with diverse build environments like CMake, Meson, and Visual Studio. Developers define 'recipes' (Python scripts) to dictate how libraries are built and packaged, promoting reproducibility and facilitating collaboration in large-scale C/C++ software development by providing a consistent way to share and consume components.

CAVEATS

Conan, while powerful, has a notable learning curve, especially for complex C/C++ projects with intricate build configurations. Ensuring binary compatibility across different compilers, versions, and settings can be challenging and requires careful recipe management. It is not a build system itself, but rather integrates with existing ones, which means understanding both Conan and your chosen build system is crucial. Proper maintenance of package recipes is essential for long-term project stability.

DECENTRALIZED ARCHITECTURE

Conan operates with a decentralized model, leveraging a local cache for downloaded packages. It can connect to various remote repositories (e.g., JFrog Artifactory, Bintray, or custom servers), allowing organizations to host their own packages and distribute them globally without a central point of failure, enabling highly flexible and scalable package management.

RECIPES AND PROFILES

Packages in Conan are defined by 'recipes,' which are Python scripts specifying how a library is built, packaged, and integrated. 'Profiles' are another key concept, used to define environment settings like compiler, architecture, build type, and C++ standard, ensuring consistent and reproducible builds across different development environments and facilitating binary compatibility.

INTEGRATION WITH BUILD SYSTEMS

Conan integrates seamlessly with popular C/C++ build systems such as CMake, Meson, MSBuild, and Autotools. It achieves this by generating configuration files (e.g., CMake toolchains, Visual Studio property sheets) that guide the build system in finding and linking with declared dependencies, simplifying the build process significantly for complex projects.

HISTORY

Conan was initially developed by JFrog and first released around 2016. Its inception aimed to bring modern, developer-friendly package management practices, prevalent in languages like Python (pip) and Node.js (npm), to the historically challenging C/C++ ecosystem. It sought to address issues like binary management, cross-platform compilation, and the complexities of decentralized repositories. Since its initial release, Conan has undergone continuous development, gaining significant adoption within the C/C++ community and evolving to support a wide range of platforms, compilers, and build systems.

SEE ALSO

cmake(1), vcpkg(1), meson(1), make(1), pip(1), npm(1)

Copied to clipboard