Installation Guide
Learn how to install and configure Conan on your system
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
makeorcmake.
2. Installing Conan
- Global installation (system‑wide):
On Windows run the command in an elevated PowerShell or Command Prompt.pip install conan - User‑level installation (recommended):
Make sure the user‑localpip install --user conanbindirectory (%APPDATA%\Python\PythonXX\Scriptson Windows,~/.local/binon Unix) is in yourPATH. - 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
conancenterby 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.txtorconanfile.pyin your project root. A minimalconanfile.txtlooks like:
Conan will resolve dependencies and generate files for your build system.[requires] fmt/8.1.1 [generators] cmake
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
--useror a virtual environment. - Missing compiler: Ensure the compiler is in
PATHand that the corresponding build tools are installed. - Network issues: Check proxy settings (
http_proxy,https_proxy) or useconan 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!