Conan.io
The C/C++ Package Manager for Developers
Navigate : Space / Arrow Keys | - Menu | - Fullscreen | - Overview | - Blackout | - Speaker | - HelpM F O B S ?

1 / 44
Hello!
Uilian Ries
C++ and Python Developer
Work at @khomp
@uilianries
  
@uilianries

2 / 44
@uilianries

3 / 44
POPULAR C/C++ PROJECTS
Because you need good libraries
@uilianries

4 / 44
OpenSSL
Qt
Boost
OpenCV
POCO
Let's start a new C++ project!
What does it need?
@uilianries

5 / 44
ALL OF THEM NEED TO BE BUILT
Download the source. Build on your machine
It may take several minutes, or even hours
There may be external dependencies
You need to know how to build
Install by system package manager
The version may not be as expected
There may be a patch applied
@uilianries

6 / 44
Build from source? Install from distro?
@uilianries

7 / 44
PACKAGE MANAGERS
How to avoid externals in your project
@uilianries

8 / 44
Python
pip, Conda
Rust
Cargo
Java
Maven
JavaScript
npm
POPULAR PACKAGE MANAGERS
@uilianries

9 / 44
@uilianries

10 / 44
CONAN
HUNTER
BUCKAROO
VCPKG
CGET
CPM
C++ UNIVERSE
@uilianries

11 / 44
CONAN
Not the barbarian
@uilianries

12 / 44
FOSS
MIT License
Decentralized, GIT style
Handles from source/binaries
Generators for CMake, VS, XCode,
qmake …
Developed in Python
+100 contributors
2K stars (Github)
CONAN
@uilianries

13 / 44
INSTALL
$ pip install conan
@uilianries

14 / 44
CONAN IN ACTION
Talk is cheap. Show me the code.
@uilianries

15 / 44
CONAN IN ACTION
Digest MD5 using Poco project
Check string by Boost Regex
Build using CMake
@uilianries

16 / 44
CONAN IN ACTION
example
| main.cpp
| conanfile.txt
| CMakeLists.txt
@uilianries

17 / 44
CONAN IN ACTION
main.cpp
#include <Poco/MD5Engine.h>
#include <boost/regex.hpp>
#include <iostream>
int main() {
Poco::MD5Engine md5;
md5.update("Hello World");
std::string md5string = Poco::DigestEngine::digestToHex(md5.d
std::cout << "MD5= " << md5string << 'n';
boost::regex expr{R"(w+sw+)"};
std::cout << boost::regex_match("Hello World", expr) << 'n';
return EXIT_SUCCESS;
}
@uilianries

18 / 44
CONAN IN ACTION
conan le.txt
[requires]
Poco/1.9.0@pocoproject/stable
boost/1.67.0@conan/stable
[generators]
cmake
@uilianries

19 / 44
CONAN IN ACTION
CMakeLists.txt - TARGET
cmake_minimum_required(VERSION 2.8)
project(example CXX)
find_package(Boost 1.67.0 REQUIRED regex)
find_package(Poco 1.9.0 REQUIRED Foundation)
add_executable(example main.cpp)
target_link_libraries(example ${Boost_LIBRARIES} ${Poco_LIBRARIES
@uilianries

20 / 44
CONAN IN ACTION
CMakeLists.txt - WITH CONAN
cmake_minimum_required(VERSION 2.8)
project(example CXX)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(example main.cpp)
target_link_libraries(example ${CONAN_LIBS})
@uilianries

21 / 44
CONAN IN ACTION
How to Build
$ conan install .
PROJECT: Installing /home/conan/project/conanfile.txt
Packages
OpenSSL/1.0.2o@conan/stable:0abbb2ea17cdc92f4a2ac8a9e55de717e
Poco/1.9.0@pocoproject/stable:8a67b44a092c0074e3cb946a9ddada3
boost/1.67.0@conan/stable:eacfdb5f448bfd89f0b2950fb6b7a79e44c
bzip2/1.0.6@conan/stable:76f87539fc90ff313e0b3182641a9bb558a7
zlib/1.2.11@conan/stable:d358fec34c04bcd89832a09158783c750a33
PROJECT: Generator cmake created conanbuildinfo.cmake
PROJECT: Generated conaninfo.txt
@uilianries

22 / 44
CONAN IN ACTION
How to Build
$ conan install .
$ cmake .
$ cmake --build .
$ bin/example
@uilianries

23 / 44
CONAN IN ACTION
Install Boost 1.67.0 binaries
Install Poco 1.9.0 binaries
CMake helper
It works for Linux, Windows, Macos, FreeBSD, ...
@uilianries

24 / 44
CONAN IN A NUTSHELL
How it works.
@uilianries

25 / 44
UNDERSTANDING CONAN
Package naming
System setup
Package distribution
Local cache
@uilianries

26 / 44
PACKAGE NAMING
name/version@user/channel
Examples
Poco/1.9.0@pocoproject/stable
Boost/1.67.0@conan/testing
Qt/5.11.0@bincrafters/stable
@uilianries

27 / 44
SYSTEM SETUP
Based on Pro les
Conan settings + Host con guration = Pro le
@uilianries

28 / 44
PROFILE
$ conan profile show default
Configuration for profile default:
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=8
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]
@uilianries

29 / 44
PACKAGE DISTRIBUTION
Git avor
Support multiple remotes
Central repository - JFrog Bintray
Easy to run a local server instance
$ conan_server
JFrog Artifactory can be used together
@uilianries

30 / 44
PACKAGE DISTRIBUTION
@uilianries

31 / 44
LIST REMOTES
$ conan remote list
my-company: http://172.0.1.42:9300
conan-center: https://conan.bintray.com
bincrafters: http://api.bintray.com/conan/bincrafters/public-cona
@uilianries

32 / 44
LOCAL CACHE
Conan Package = 1 recipe, N binary packages
@uilianries

33 / 44
PACKAGE ID
$ conan search boost/1.67.0@conan/stable
Existing packages for recipe boost/1.67.0@conan/stable:
Package_ID: eacfdb5f448bfd89f0b2950fb6b7a79e44c7ea08
[options]
fPIC: False
shared: False
[settings]
arch: x86_64
build_type: Release
compiler: gcc
compiler.libcxx: libstdc++
compiler.version: 5
os: Linux
[requires]
bzip2/1.0.6@conan/stable:76f87539fc90ff313e0b3182641a
zlib/1 2 11@conan/stable:d358fec34c04bcd89832a0915878
@uilianries

34 / 44
CREATING PACKAGES
How a recipe looks like.
@uilianries

35 / 44
CREATING PACKAGES
from conans import ConanFile, CMake, tools
class HelloConan(ConanFile):
name = "hello"
version = "0.1.0"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
cmake.install()
def package_info(self):
self cpp info libs = ["hello"]
@uilianries

36 / 44
CREATING PACKAGES
conan create . uilianries/testing
hello/0.1.0@uilianries/testing: Exporting package recipe
hello/0.1.0@uilianries/testing: WARN: Forced build from source
hello/0.1.0@uilianries/testing: Installing package
Requirements
hello/0.1.0@uilianries/testing from local cache - Cache
Packages
hello/0.1.0@uilianries/testing:56e0cf6d16ee57367a0661ab743f4e4
hello/0.1.0@uilianries/testing: Building your package in
hello/0.1.0@uilianries/testing: Copying sources to build folder
hello/0.1.0@uilianries/testing: Generator cmake created conanbuil
...
@uilianries

37 / 44
COMMUNITY
Sharing data is the rst step toward community.
@uilianries

38 / 44
github.com/conan-io/conan
@uilianries

39 / 44
docs.conan.io
@uilianries

40 / 44
BINTRAY AS DOWNLOAD CENTER
Frog’s solution
Conan Center: +100 recipes
https://bintray.com/conan
@uilianries

41 / 44
Packaging OSS Software
~20 members and growing
+200 recipes, including:
Boost, Abseil, Azure, Qt
Thanks to @solvingj, @SSE4,
@gra kbot, @theirix, @madebr
BINCRAFTERS
https://bincrafters.github.io
@uilianries

42 / 44
REFERENCES
https://github.com/conan-io/conan
https://github.com/bincrafters
https://conan.io
https://docs.conan.io
https://github.com/memsharded/four-c-example
CppCon 2016: Conan, a C and C++ package
manager for developers
https://bintray.com/conan
Programming C++ With The 4 Cs: Clang, Cmake,
Clion And Conan
@uilianries

43 / 44
THANK YOU!
Questions ?
You can nd me on:
@uilianries - twitter, github
cpplang.slack.com - channel #conan or
#bincrafters
uilianries@gmail.com
https://conan.io
@uilianries

44 / 44

Conan.io - The C/C++ package manager for Developers