Installation Guide

Learn how to install and configure Conan on your system

guide

Conan is a modern, Python‑based package manager that streamlines dependency handling, builds, and distribution for C and C++ projects. This guide walks you through the essential steps to get Conan up and running on Windows, macOS, and Linux, and shows how to integrate it with CMake in a way that feels natural to developers of all experience levels.

1. Prerequisites

  • Python 3.7+: Conan 2 requires Python 3.7 or newer. On Windows you can download the official installer or use the Microsoft Store. macOS and Linux usually ship with Python pre‑installed, but you may prefer a virtual environment or a package manager such as Homebrew, apt, or dnf.
  • pip: The Python package installer is bundled with recent Python releases.
  • Build tools: To compile C/C++ code you need a compiler and build system.
    • Windows: Visual Studio 2019+ (MSVC) or MinGW‑w64.
    • macOS: Xcode command line tools (xcode-select --install).
    • Linux: GCC/Clang plus make or cmake.

2. Installing Conan

  • Global installation (system‑wide):
    pip install conan
    
    On Windows run the command in an elevated PowerShell or Command Prompt.
  • User‑level installation (recommended):
    pip install --user conan
    
    Make sure the user‑local bin directory (%APPDATA%\Python\PythonXX\Scripts on Windows, ~/.local/bin on Unix) is in your PATH.
  • Virtual environment (isolated projects):
    python -m venv conan-env
    source conan-env/bin/activate   # Linux/macOS
    conan-env\Scripts\activate.bat   # Windows
    pip install conan
    

3. Verify the installation
Run conan --version. The output should display the Conan version and the path to the Python interpreter it is using.

4. Basic configuration

  • Conan stores user settings in ~/.conan (Linux/macOS) or %APPDATA%\conan (Windows).
  • Default remotes: Conan uses conancenter by default. You can list, add, or remove remotes:
    conan remote list
    conan remote add myremote https://myremote.com
    conan remote remove myremote
    
  • Project file: Create a conanfile.txt or conanfile.py in your project root. A minimal conanfile.txt looks like:
    [requires]
    fmt/8.1.1
    
    [generators]
    cmake
    
    Conan will resolve dependencies and generate files for your build system.

5. Using Conan with CMake
Add the following to your CMakeLists.txt:

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

Build the project:

mkdir build && cd build
conan install .. --build=missing
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .

6. Advanced configuration

  • Profile customization: Create custom profiles in ~/.conan/profiles/. A profile can set compiler, architecture, build type, etc.
    conan profile new myprofile --detect
    conan profile update settings.compiler.libcxx=libstdc++11 myprofile
    
  • Environment variables:
    • CONAN_USER_HOME – override the default user directory.
    • CONAN_LOG_LEVEL – set verbosity (debug, info, warning, error).
    • CONAN_CACHE – point to a different cache location.

7. Common troubleshooting

  • Permission errors: Use --user or a virtual environment.
  • Missing compiler: Ensure the compiler is in PATH and that the corresponding build tools are installed.
  • Network issues: Check proxy settings (http_proxy, https_proxy) or use conan config set general.proxy="http://user:pass@proxy:port".

8. Uninstalling Conan
Run pip uninstall conan. If you want to clear all caches and settings, delete the ~/.conan directory.

With these steps you’ll have a fully functional Conan setup that keeps your C/C++ dependencies tidy, reproducible, and easy to manage across different platforms. Happy coding!