Italian C++Community : Conan Package Manager for C++ in Practice

October 14, 2021

< 1 min read

Italian C++ Community: Conan Package Manager for C++ in Practice
Talk description: The Conan package manager for C++ is useful in both simple and advanced development environments. Join the Conan team to see it in action, with a simple demo using OSS libraries and tools from ConanCenter, and a more complete demo showing how to create and upload a package including different binaries for different platforms to a private repository. Also, learn about many other unique and innovative advanced Conan features along the way.

The source code for the resource slides can be found here: https://github.com/memsharded/meetup_code

View Slides Here

Speakers

Diego Rodriguez-Losada Gonzalez

    Diego Rodriguez-Losada Gonzalez

    Diego Rodriguez

    Diego Rodriguez-Losada Gonzalez 's passions are robotics and SW engineering and development. He has developed many years in C and C ++ in the Industrial, Robotics and AI fields. Diego was also a University (tenure track) professor and robotics researcher for 8 years, till 2012, when he quit academia to try to build a C / C ++ dependency manager and co-founded a startup. Since then he mostly develops in Python. Diego is a conan.io C / C ++ package manager co-creator and maintainer, now working at JFrog as senior SW engineer and C / C ++ advocate.

    Video Transcript

    hi everyone
    hi diego how you doing there hello ciao
    we are here for the first time on hybrid
    meetup
    with a bunch of people here attending so
    show you make some noise make some noise
    folks yeah
    this is this is really nice to have some
    people in front in a real yeah
    in a real room we have a big television
    here in front of us so people can
    watch the the session live
    we have stream yard streaming the video
    on youtube this is kind of a new setup
    for us but i think it’s going places so
    nice thanks diego for uh accepting the
    invitation and uh
    thanks for the for the great session i’m
    going to give i’d love to be there in
    person but as a substitute i think it
    will be this will be nice thanks thank
    you very much for inviting me
    now thanks diego next time next time a
    few people are
    welcoming us uh saying something bona
    cera by julian and rui ola hola guys
    and leonardo bono
    okay i think
    we we can start the session diego
    and
    let’s try this very first form of a
    hybrid meter for the italian superstars
    community thanks diego
    perfect
    thank you marco
    thank you everyone so yeah my name is
    diego and i am one of the conan
    co-founders and today i’m going to give
    you an introduction to conan
    but i wanted to prepare something
    something special so today’s session has
    two parts
    the first one is the is let’s say the
    relatively easy and common stuff which
    is using existing packages
    first packages that someone created for
    us and we’re just going to consume them
    and use them and then we are going to
    learn how to create our own package and
    upload it to our own server but i am
    going to do this part with all the new
    integrations i’m going to do a special
    focus on the cma transparent integration
    that we have already
    released is available today in conan 140
    and quantum 141 so i’m going to explain
    this new integration for this for this
    flow and then for the most advanced
    advanced users i’m going to explain two
    advanced use cases the first one is how
    can you work on multiple packages the
    source code changing the source code of
    multiple packets at the same time which
    is the editable feature and i’m also
    going to do a demo of cross building
    with the build and host profile to to
    enable advanced cross building scenarios
    so let’s start first with a brief
    introduction for those that are newbies
    for to conan colon is a package from cnc
    plus plus it is open source mit license
    so you can do with it whatever you you
    want it runs in any platform and can
    target any platform actually today we
    are going to cross build to android for
    example
    and it can integrate with any build
    system i’m going to use today a lot of
    cmake but even if you have visual studio
    and i mean native visual studio
    solutions or make files or meson or even
    your properties system conan can use it
    it is a stable project it has been
    running in conan one
    from one zero to 141
    versions one release per month without
    breaking and it has a very active and
    amazing community really really helpful
    in conan center creating packages doing
    contributions helping
    each other in in the slack and discord
    channels
    so the community is one of the best
    things of of conan
    uh regarding the architecture conan is
    using the typical server client
    architecture the centralized
    architecture so we have the j4 conan
    center repo which is a server that that
    contains the
    packages of popular open source
    libraries these are the packages that
    the community is creating is
    contributing them to the center so they
    are available for other users
    but you can very easily host your own j4
    artifactory instance we have a community
    edition which is completely free and if
    you want to store there are your own
    packages your own private packages for
    free you can do it and then you can have
    the client that is downloading packages
    from content center or from your own
    artifactory instance or both if you want
    one of the most important features of
    conan is the way that it manages the
    binaries and we will see today in action
    but i wanted to give the big picture
    first
    for every package we have a recipe a
    recipe is a python script
    that describes how a package is built
    from sources and packets from sources
    okay
    every recipe can create any number of
    binaries for every different
    configuration every different platform
    or compiler
    that recipe will create its own binary
    and conan will store and manage all
    those binaries connected to the recipe
    that created them together
    if we
    focus a little bit more on this model
    we can introduce the package id concept
    the package id concept is a hash it’s
    the hash of the configuration that is
    used to create that binary so for a
    given recipe let’s say in this case the
    mylib 1.0 recipe that python script if
    we build this package with a set of
    options
    for example we here in the right side we
    can see a set of options the settings is
    the compiler the operating system the
    architecture the build type compiler
    version
    and if it is a static or a search
    library okay we take this this
    configuration we has it and then we get
    the first package id
    if we change change something in this
    configuration for example we change it
    from being a static library to vienna
    cert library then the binary will be
    different and we will get a different
    package id because hashing the contents
    of the configuration results in a
    different hash and a different package
    id and also if we now change the build
    type from release to debug the binary is
    a different one and it will be managed
    under a different package id because the
    hash of the configuration is also a new
    hash
    okay this is concept is very important
    we will see today live in action we will
    be creating packages for different
    configurations
    and see how it works
    uh creating multiple multiple binaries
    for the same package doesn’t mean that
    kernel is significant actually current
    is very efficient because when you’re
    building what you require a package
    and you can have
    even if you want 100 different binaries
    in the server actually we do in content
    center we are building
    uh binaries for more than 100 different
    configurations for these open source
    libraries
    but when you are installing and when you
    need to build your application and you
    do a conan install
    only the binary for your configuration
    is downloaded this means that
    working as a developer is fast and
    efficient and also for ci jobs is very
    efficient because you only download
    exactly what you need for that specific
    build
    the other important concept of conan is
    that it abstracts away build systems
    as i’ve said i we are going to use today
    uh cmake a lot
    but
    uh it is not compulsory you can have
    different packages using different build
    systems
    and this is actually what we have in
    column center we have
    all these packages they are not using
    always cmake to be to be built they are
    using different build systems
    so you can create packages with any
    build system and you can can consume
    those packages with any other build
    system not necessarily the same one and
    you can mix them
    we will see them later how how it works
    okay so as you can guess i don’t love
    slides i’ve gone fast through them and
    i’m going to start
    the live live demo hopefully everything
    goes
    goes
    well i’m going to start with the example
    of how to use existing packages packages
    that someone created for us and i’m
    going to show two examples first using
    lib curl and then using cmake
    cool here i have some code this code uh
    i have it in a github repo if you are
    interested i will share the the github
    repo after the after today
    meetup
    okay so let’s
    i’m going to introduce you to this
    little example here
    i’m going to build a small application
    an application that is going to do an
    http
    get request
    to a server
    and for doing this i’m going to use the
    lip color library
    this is the main
    it has nothing special just using the
    the curl
    library
    in this case it’s doing a get
    to a to a url that is being specified in
    the command line and printing the
    results of the of the get http request
    this is not very relevant for for us
    today what is really relevant for us
    today is this
    this is the syma list to build my
    application
    as you can see here there is absolutely
    nothing related to conan in dc make list
    it’s absolutely agnostic to column but
    we are going to use conon dependencies
    but you don’t need to modify your cmake
    list to account for these dependencies
    okay what we need to do is we need to
    tell conan that we need to
    to install we want to fetch the lib code
    library from in this case from content
    center
    and i need to specify which version i
    want to use so for this i’m going to
    write a command file.txt file which is
    the simplest form of a command file
    the first important section that i’m
    going to specify here
    is the requires i specify here the the
    packages that i want in this case i
    won’t leave curl and i want this
    specific version you can specify an
    older version if you if you need it or
    the latest one as you wish
    and finally i’m going to specify my
    build system in this case i’m using
    cmake so i want conan to generate the
    necessary files
    to integrate with my cmake build in this
    case i want to generate files for my
    dependencies and i want cmake to
    generate a toolchain file so i can call
    it transparently so this is all i need
    for conan to install my dependencies
    let’s do it let’s create a build folder
    and i’m going to call
    conan install
    gonna install
    the first thing that you will see here
    okay is that conan install is style is
    installing a few things it’s installing
    not only core but it’s also installing
    other libraries why because those are
    transitive dependencies of lip core
    so if i inspect i actually can print
    my dependency graph
    i can see
    that
    this is what i have i have dependent on
    a lip color but liquid transitively
    depends on open ssl and
    and this is the reason
    why when i did a conan install
    the three dependencies
    were were required
    then
    this was very fast
    why because conan found binaries for my
    config for my configuration pre-compiled
    binaries in conan center for my
    configuration as you can see i i’m using
    windows why because typically let’s be
    honest it’s the most challenging
    platform if i can make this working
    windows it probably works
    in the other platforms conan works
    exactly the same in other platforms you
    move to linux and this demo works
    exactly the same okay same commands same
    everything
    and it will also work
    uh so yeah i got pre-compiled binaries
    so they were
    downloaded it was everything was very
    fast and finally as i specified the
    generator simic depths and simic tool
    chain
    conan generated some files for me
    actually it generated some config files
    for the different
    libraries open ssl said deep curls so
    these dependencies can be correctly
    found and it generated a conan tool
    change dot c make for me
    then from now is just a standard
    cmake stuff i could do conan tool chain
    this will create a project this will
    launch the cma configuration step in
    this case as i’m using
    windows and visual studio it’s going to
    generate a visual studio project of
    course i could open the ide and and
    build from my id but in this case i’m
    going to
    to build from the command line which is
    a bit more convenient
    for demo purposes
    this will be building my
    micro application and now i could
    run my application
    yes it seems doing something okay i
    didn’t provide a url
    let me check
    yeah this one for example
    as many developers i guess some of you
    who love scats
    someone with your hands
    loving
    cat lovers there no one yeah some of
    them
    i guess
    so
    we can
    ping this do a get request to this url
    that contains some some cat facts
    and if everything works we should
    see here a fact some notable people who
    dislike the cats napoleon bonaparte
    eisenhower hitler okay
    good
    it seems that our application is is
    running and it’s it’s working
    okay nice so we built our first
    application using some conan
    dependencies
    which was a library we we use sorry
    marco do you have any question there
    no i don’t hear you by the way
    it’s uh no questions here i was trying
    to enable my the microphone of the
    laptop
    but this way you get some return noise
    so i can’t do it so if i don’t worry
    questions i can just pass the headphones
    on sorry for the interruption but no no
    no problem yes let me know
    okay so i was i was saying that we have
    used a library okay but very very soon
    in the very first version of conan
    people started asking us hey what if i
    put
    a an application like cmake itself into
    a conan package can i use it later
    and then this resulted
    in the concept of build requires
    okay and now it happens that we have
    some tools
    packaging content center
    and you can also package your own tools
    whatever you need
    as conan packages and then you can use
    them as we requires
    a very important concept here
    conan does not modify your system it
    will not install cmake at the system
    level and to be able to use this
    cmake 320 i need to enable
    a virtual environment
    and i’m going to do this via the virtual
    sorry
    build environment generator
    and i will see i will show you how it
    works
    okay so now i have specified
    that when i’m going to install
    let’s do it again
    now
    my application will
    depend on lip coral or pencil and sleep
    as it did before of course i haven’t
    removed this dependency but now
    as build requirement it is depending on
    simic 320
    okay now it is
    unseeping cma320 let’s give it a second
    to finish
    okay it did finish
    the last run when i i i built my micro
    application i was using my
    system
    cmx which is
    you can see that i have here in my
    system i have installed cmake and this
    cmake is 315.
    so this was this image that was built in
    my previous micro application
    okay now i have installed simic 320 as
    appeal required
    okay it didn’t modify the the system
    yet what it did for me it generated a
    script
    a script with environment variable
    i can do run up conan build dot pad
    it change the environment so now if i
    ask hey
    which
    c make
    and we can see that this is pointing to
    a cma320 that is inside the cone and
    cache
    so whenever i run
    now cmake
    is going to be 320.
    okay so i could build now my application
    every everything will be running cma320
    you can install in parallel as many
    simic versions as you want
    and if at any point you want to return
    to the previous one
    you deactivate the environment and then
    you are back
    to the system
    cmake
    okay
    so this is a
    powerful feature which is called the
    build requires you can put tools there
    and then use them very very easily as
    well
    we will use these build requests again
    in the cross build example
    any questions so far
    okay let’s do then a brief recap of what
    what we have done we have learned
    how to write a conan file.txt and call
    conan installed to install dependencies
    and transitive dependencies
    from there we can just call cma
    native cmake
    pass in the content toolchain
    and then everything will work we have
    seen that the cmake tool chain and
    cmctape’s new integrations they can
    provide a fully transparent integration
    that means that you don’t need to modify
    your cmake list at all we have also
    learned how to use build requires an
    activate environment to activate those
    tools without changing your system
    thanks many thanks to the creators of
    these packages now in the conan center
    there are more than 1000 recipes every
    recipe can contain multiple versions and
    every version can contain more than 100
    binaries so this is is created by the
    community an amazing community so many
    thanks to to this to these people
    if you don’t find
    a binary in conan center for your
    configuration the recipes themselves
    they know how to build from sources so
    if you do a conan install and it tells
    you hey i don’t have a binary for this
    configuration then you need to add call
    and install das das bill
    to force appeal from sources and then it
    will start it will launch a bill from
    sources for the for the packages that
    don’t contain the binaries in conan
    center
    okay then now let’s move to a
    learning how to create our own packages
    right and then we are going to have a
    library we are going to create a package
    for it and then we are going to upload
    this package and the binaries to our own
    server
    let’s
    go
    to the source code
    and then i’m going sorry give me one
    second to
    clean this up for later
    okay
    this is the library that i want to
    create a package for
    this is a very example one
    sorry a very simple one
    a hello hello world one
    just a single function
    and this function will contain some some
    output to std out
    uh some messages
    hello messages and also some some
    diagnostics about the architecture the
    compiler and everything just to make
    sure that everything is working it’s
    working correctly
    okay so very simple uh c plus plus
    library hello world library
    again
    now that we are using the transparent
    integration the cmake list to create a
    package is still your own one it doesn’t
    contain any kind of specifics here
    okay this is a
    library
    from these sources i’m building the
    hello library
    the header of the library is this one
    and then i’m using the cmake install
    filter to specify which are the
    artifacts
    that form the final package of this of
    this library
    okay nothing really different nothing
    really commonly specific in this cmg
    list
    but let me introduce the conan file dot
    py to create a package the conan
    file.txt that we were using
    earlier is a very simplified form of
    this that is only used for consuming
    existing packages if we want to create
    packages we need to provide a icon and
    file.py recipe this is a python script a
    python script that contains a few
    important sections that i’m going to to
    summarize now
    first one the metadata name and version
    of the package for example
    next important part the binary
    configuration this is the binary model
    this means
    if you are changing anything in your
    configuration like the operating system
    or the compiler or the build type or the
    architecture you are going to get a
    different binary
    and furthermore inside compiler there
    are compiler.version compile.try time
    compiler standard
    library
    that you wouldn’t need to declare here
    but they are sub settings that also
    affect the binary configuration
    then we have the options in this case we
    are declaring that we can build a static
    or a certain library
    as as we as we want okay if we change
    any of those inputs we will get a
    different binary
    let me skip these two parts here because
    they are not really relevant and let me
    focus on the new stuff
    these are the important methods
    of the recipe
    okay let’s start with the layout
    the layout is a new feature it’s very
    new from conan 139
    and and quran 140 and 141 the latest
    releases
    it is useful to specify where the things
    are this predefined
    simic layout
    function here
    specifies the typical cmake layout
    typical cmake layout will contain
    a scenic list like this one in the root
    of the of the repository when you call
    cmake it will be creating a certain a
    certain structure of folders this is
    what this cmake layout is is
    representing you can customize this
    the idea is that
    anytime you have something special for
    example you don’t have the simic list in
    the root then you can specify something
    like a self
    folders dot source
    equal source you could do this and then
    this means that you will have the cmc
    list will be inside the source folder
    and the root of your source is not the
    the root of the repo but the source
    folder
    okay it’s not very important to know all
    the details yet that this method here
    represents the the local structure of
    your of your source code and your
    project
    next method the generate method this is
    completely equivalent to the generator
    section that we saw in the quantum
    file.txt in this case we are telling
    that we are going we we want to a conan
    toolchain.cmg file because we are going
    to use it
    the important part here and what i
    wanted to
    show this section this this method here
    is because you can also customize a lot
    of things here if you want to
    people say
    so
    directive
    you could add here something
    and a value and there are ways that you
    can customize this sim symmetrical chain
    as your at your will in this function so
    if you want to inject your own values
    change some of the of the con and
    defaults because the schema tool chain
    contains some some default logic you can
    customize it very very deeply
    the build method is a very thin wrapper
    around the semicon cmake command line
    this semiconfigure
    is basically the same as as running
    cmake
    and passing the toolchain file creating
    the project and the cmake build is
    basically the same as of calling cmake
    that’s just built
    you could actually
    try it yourself and you could replace
    something like yourself run
    cma that’s the spill
    and it will do basically the same
    so if you have here your own build
    system
    is just a matter of calling your build
    system with the arguments that you need
    to produce the build that you want
    the package method exactly the same
    the goal is once the build has finished
    it will copy the artifacts from the
    build folder to the final package folder
    this this is a thin wrapper on the cmake
    command line which is equivalent to be
    calling the cmake dash as installed
    and finally this important package info
    method is the information for the
    consumers this is the bit of information
    from conan that’s decoupled the build
    system
    this is telling the consumers hey if
    when you are using this package you are
    going to link with a library that is
    called hello
    okay if the library name changes it is
    ready to change this way why because
    simic information is not enough if you
    are going to consume this package
    directly in visual studio you need
    someone to tell visual studio the name
    of the library is hello.lib
    and this is the place that this
    information will be will be contained
    cool so with this recipe
    creating a content package
    is calling conan create and dot
    with this command it would be
    firing the different recipe methods
    calling generate
    generating the files
    calling
    cmec the build method the build method
    will be calling first the configure step
    creating the project
    for us as you can see here it is using
    my default configuration again as i
    didn’t specify anything special it is
    creating the package for my default
    configuration finally is calling the
    package
    and we have here we can see that the
    artifacts that are being put into the
    package are the header and the library
    itself
    so if i do a command search everything
    was local in my machine of course this
    is a local bill that was produced in my
    conan cats if i do a conan search
    it will tell me that the recipes that i
    have in my cast are these ones
    the previous ones that i used for the
    previous example
    and then i have the hello 0.1
    packet in my local cache if i further
    inspect
    the the hello
    package
    i will see that i have one binary
    okay the binary that was created for my
    default configuration which is visual
    studio
    64 bits
    dynamic runtime compiler version is the
    16
    and so on and this is the package id
    which is the hash of this simplify way
    but basically it is
    let’s say that now i i need to maintain
    this this important library in my
    company and we are deploying this
    library for some atm machines that they
    happen to run in windows in an older
    windows version and which is 32 bits and
    i need to run
    to link with the static runtime and i
    need to use an older compiler version
    because
    a new new comparison won’t run with one
    drone running that in that machine at
    all
    so i can just repeat the cone and create
    process and in this case i’m going to
    specify the specifics i’m going to say
    that my version is to be 15 instead of
    16
    i’m going to tell that the compiler
    runtime
    is going to be the static one to be
    deployed in that atm
    machine
    and i’m going to specify for example
    that my architecture is going to be 32
    bits because the
    place the machine where this this hello
    library will run for this binary will be
    32 bits
    and now the process of creating the
    package calling the generate calling the
    build method calling the package method
    will be called again in this case we are
    using visual studio 15 and it will be
    passing the right parameters the right
    arguments like the architecture and so
    on so the library is built
    correctly for this for this
    configuration
    if we now specify
    sorry if we now inspect again the
    package binaries that i have in my local
    account and cash
    i can see that i have these two
    different binaries i will have my first
    binary for my native desktop
    system and i have this binary which is
    the one for the atm machine which is
    using the 15 32 bits and runtime static
    furthermore we can
    use uh we can crossfield for example we
    and now we are going to cross build to
    an android application let’s say that
    this same library is deployed in some in
    some android application that we are
    maintaining as native code for
    efficiency
    how to do this so first i could be
    launching this and instead of this i
    could be passing here
    is going to be an arm v7 is going to be
    the operating system could be android
    as you can guess this is not a very
    practical way
    of managing configurations
    so instead of this
    what i’m going to do is to use a profile
    file this is the way that is recommended
    to use in production when you are
    maintaining different binaries for
    different configurations instead of
    passing them on the in the command line
    all the time
    you need to put the settings and the
    configurations in a file like this one
    and uh you want to use this file all the
    way conan has mechanisms to share this
    file by the way so this file can be put
    in the ci machines in the developer’s
    machine very easily so here we can see
    that we have the settings for this
    binary which is android
    api level 23 the compiler version and so
    on and now i want to introduce a new
    mechanism of the
    new modern corner mechanism which is the
    new configuration that can be also
    defined in profiles
    this is specifying things like for
    example where is my android ndk
    in this case i installed the android ndk
    in this path in my system
    so it can be located and also i want to
    specify that for this
    build i want to use the ninja generator
    because instead of the mingw because
    ninja as we know is fast and it’s very
    cool
    so we can specify just keep that there
    is a new mechanism for configuration
    it’s more powerful than we were using
    before which was environment variables
    and were more structured
    so
    with this profile we could go to the
    command line and specify
    the profile instead of a bunch of
    settings and options in the command line
    which is more error prone so if we
    create the package now for the android
    profile
    we will see that the bill
    sorry about that the bill is now
    sorry
    now
    as you can see here this is using the
    the compiler that is within the android
    ndk that are installed in the in the
    system we can see that we are we are
    using the ninja
    simic generator
    and we can see here that the final
    binaries are being built
    i can guarantee i was just for for
    christy yes i was trying i i tried to
    move these libraries and these
    applications built this way to an actual
    android device and and it works
    the actual the integration with the
    cmake of the android ndk is pretty it’s
    pretty cool
    so
    now
    if i do a content search
    i will see that i have these three
    different binaries
    okay i will have the android one here
    with this configuration and this package
    id
    i will have my windows desktop one
    here and i will also have the windows
    atm legacy
    32-bits binary here
    okay and this is the the basics of the
    of the binary model
    now the thing is okay we created these
    three packages here in my computer
    but what i want is i want to share this
    this
    these packages with my team
    and my company so they can reduce them
    they can use them
    in ci so they don’t need to rebuild over
    and over these libraries from sources
    because in the real case hello will be a
    library a big library that takes a
    bunch of time to to be compiled so i
    want to share these these packages with
    my team
    so welcome to
    artifactory okay so artifactory is the
    jfb server in this case i’m using here
    artifactory ce community edition which
    is completely free for conan packages so
    you can use this
    commercially professionally your company
    completely for free both the client
    which is mit and the server
    here we can see we have a conan local
    repo you can have as many ripples as you
    want
    and we can get the url of this ripple
    and this is all we need
    to be able to upload packages to this
    rip
    so i’ve already added this remote
    to my
    to my local content client
    and now i can do a content upload
    i will upload the hello package
    to my artifactory remote
    and i want to upload all the binaries
    that i did create
    yes i do so now conan is uploading the
    binaries
    let’s have a look at the art factory
    and here we have the hello packets we
    have the hello package zero point
    version
    if we go down a little bit in the in the
    in the folders
    we will see that we have these three
    different
    different binaries
    if we further inspect them we will see
    that we have the the
    package for the android
    here
    we have the package for the windows
    desktop machine
    and we will have
    the package for
    for the windows uh for the atm machine
    okay and this is very cool because now
    even if you
    handle you need to manage many different
    linux build and different linux distros
    and compiler and compiler versions you
    want to introduce a new compiler version
    you don’t break anything you just build
    the new binaries for the new for the new
    compiler version they they are uploaded
    there previous wheels with the previous
    compilers they don’t break they keep
    using the
    the previous compiler version and then
    you can start
    just pushing a new compiler version very
    very easily
    also you will see you will realize
    something that besides the hello package
    i have leave curl open ssl setup and
    cmake here this is something that you
    can do actually it is recommended to do
    this instead of depending directly from
    conan center what i did today just in
    case the network is wrong demo effect
    whatever i didn’t pull the artifacts
    directly from conan center i did a copy
    of the artifacts to my artifactory
    instance and now i am completely robust
    against any failure and nothing can
    break
    this is recommended for you in
    production if you are even if you are
    going to use quantum center packages
    having your own anti-factory instance
    doing a copy there of the packages that
    you are using is a very good practice it
    is the way that we want that the npm the
    vehicle the practice of the left path
    and everything won’t happen to us if we
    are
    if we are doing these best best
    practices
    excellent so now that the
    hello packages
    are in the server we could perfectly
    sorry we could perfectly
    remove the hello package from my local
    client
    and no retrace anymore
    perfect so now the packages are there
    that means
    that
    we can go back to the previous project
    remember the micro application we are
    going now to use the hello package in
    the micro application
    let’s do it
    let’s see how it works to have a package
    manager in place
    all i need to do is i need to include
    the hello.h
    i’m going to call the hello function
    like here
    this is managed
    in native
    cmx syntax
    so if you move hello to another
    mechanism not managed by conan this
    syntax will still be the same
    hello
    and finally i’m going to add the hello
    dependency here
    in my column file
    that means that now if i do a conan
    install
    it’s going to depend on hello
    it’s going to download the hello from
    the artifactory
    it’s going to download the binary
    directly the binary no need to rebuild
    again
    so if i now rebuild my application
    i have just reused the library that i
    created from the conan package from the
    server that was pulled into my
    into my local project
    and i can see here the hello dependency
    doing its stuff and printing its
    messages
    okay let’s do a
    brief recap of what we have done we have
    learned how to create packages specify
    different settings different
    configurations to to create different
    binaries we have learned about the
    profile and how using profile files is
    recommended to manage configuration
    we have learned how to upload those
    those packages and those binaries to um
    to our own artifactory server and how
    can we use these uh these packages later
    in other projects in in our teams and
    our companies
    uh
    this is i i rarely say this is a good
    practice using art factory ce to have
    independent isolated efficient and
    robust fields is a recommended practice
    conan center is very cool
    but if you want to be rock solid
    better use an artifact 3c instance both
    for third parties and your own private
    packages
    okay so this was the
    basic stuff we have learned how to use
    existing packages and how to create own
    packages but now i’m going to move into
    a more advanced territory
    which is
    more enterprise use cases
    vale is something that many conan users
    have been asking for
    is hey diego what happens
    now i need to work
    on these two packages at the same time i
    need to be changing the source code of
    the hello package and
    the micro package at the same time
    and this can be painful because we what
    we have done is is we have
    we have modularized we have completely
    decoupled micro from hello they can have
    different versions they
    they are they are they can be developed
    so this is what we have right now
    we have the hello package and we have
    the micro
    application
    okay
    whenever
    we do source code changes
    to the hello package
    then we need to do a conan create
    a new one
    so this package is created in the cache
    and it is made available for the micro
    consumer
    the bills in the cache are always
    from scratch
    they are not incremental bills the
    library and this is very important they
    guarantee that it’s a clean bill
    this is always correct
    and and it cannot do incremental
    building in the cash it will never do
    that that means if you’re if the
    building the hello library is heavy and
    takes a few minutes
    this is very painful because you need to
    do the the source code changes come and
    create wait for a whole bill
    then go to my curl
    and
    and build micro again
    okay so we we
    we heard uh developers we we really take
    feedback seriously so this is one of
    these we have been developing this is
    one we have been iterating if you knew
    about editables before we have changed
    how they are they are used
    so the first important bit
    okay so what we i really need
    is i want the hello package
    to be
    locally modified and locally built
    okay i don’t want to do a conan create
    that is a
    building the cast i want to have my
    local flow as a developer of the hello
    package the local flow means exactly the
    same
    as we did for micro which means quantum
    install to install the dependencies of
    hello because hello itself can have
    dependencies okay and then call cmake
    this is what i’m going to do right now
    i’m going to move to the create
    project
    and i’m going to do
    exactly the same is
    typically create a folder
    move to the folder
    then do a conan
    install
    in this case i also want to to
    showcase um
    one of the use cases that is important
    for especially also for for people using
    multi-configuration environments in this
    case visual studio if you know a bit of
    windows or xcode there are
    multi-configuration environments that
    means that you can switch from debug to
    release directly in the ide
    okay as i want that experience i’m going
    to install for the for the
    hello package i’m going to install both
    configurations i’m going to store the
    release one which is the default
    and i’m going to install the debug one
    as well
    okay and then again is i going to create
    my project
    calling cmake
    this will generate my my visual studio
    project and solution
    this is exactly the same steps as i did
    for my crore before
    it’s installing calling code install and
    calling cmake
    to configure the project
    and build the things
    i could build the release configuration
    of the
    of the hello library
    and i could be the debug one
    okay everything is in place this is what
    i got okay but still
    so far if i now go to my curl
    uh
    project
    if i do an install it will still get the
    the dependency from the cash
    this is what can be changed with the
    conan editable ad
    if i say this command i’m telling a
    whenever you find the hello 0.1
    don’t go to the cache go to this folder
    the folder is the dot folder is the
    current folder because in this folder
    you will find
    the release hello.leave you will find
    the source hello.h that you need
    from there so this is the thing the
    important bit that changes
    the location of the of the dependent
    package
    let’s do it
    conan editable ad
    just in case there are several content
    commands that you can use for how you
    can list the packages that you have in
    the table mode and where they are
    located
    so in this case you can see that this is
    my folder
    and it is not a folder in the cache
    okay so with this in place i can go to
    the use
    build
    and for the use break is
    just call and install
    when i do go on install now
    in the in the consumer project in my
    cool project this is what i will get
    it will tell me that it still depends on
    leaf curl opens around sadly they are
    found in the cache
    but now hello is not in the cache hello
    is an editable package it is in expected
    to be found in your local folder
    okay i can do the same
    for build type equal
    debug okay in this case it’s installing
    the back dependencies
    as well
    and
    from now it’s just
    useful stuff
    calling cmake
    and we’re done
    and now is when i i wanted to show you
    now we have everything in place we could
    be coding we have the two projects
    connected
    okay i could be
    typing from the from the terminal but
    i’m i want to show you that with a
    couple of uh
    of clicks what can be done i’m going to
    open visual studio solution
    okay of the micro
    example
    this will take a bit of course it’s
    visual studio
    and yeah come on visual studio
    you can do it
    excellent
    so one of the cool things
    of having ideas and other tools
    is
    that you can do things like this one you
    can say hey i’m going to add you
    the other project
    and i’m going to tell you
    that this is a dependency
    and we got it
    now
    we can be working for hours yes it took
    a a couple of clicks it talks to set up
    a little bit but now
    i can be working in this setup for for a
    few days and now i will have both things
    in the same place i can show you i can
    execute
    the micro application it is building
    from source
    it will be launching
    and here we can see that it is depending
    on the hello package and it is also
    doing its stuff
    and the cool thing that
    is
    now i can of course change the source
    code of the hello package of the
    dependency
    i can type here
    buy
    buy
    and of course it will do incremental
    builds
    it will
    build what is necessary
    and it will launch
    now the application
    changing the
    the message and i can be working
    together with the with two or more if
    you want to have several packages
    at the same time you can do it
    this is the multi-configuration step uh
    stuff you can change directly to the bug
    in the ibe
    okay and you can be
    also
    launching the debug configuration
    you can build and change the announce
    the diva configuration
    here we will see now that we are
    running the the debug configuration
    including the efficiency of the hero
    package and we can step into
    of course we can debug
    and
    we could launch our application
    and it will step
    it will go into the source code of the
    dependency we can stop here
    and then of course we could continue
    and this
    okay
    so this is
    the editable feature in action
    and
    honestly i i’m really excited about
    about this feature because this is what
    achieves the best of both worlds when
    you are using a package manager you
    modularize things you decouple things
    and then there is the pain when you need
    to work and this really happens in in
    enterprise and in companies with huge
    projects
    that they need to work on more than one
    package at a time
    and this can be painful if the necessary
    tools are not there with this we are
    enabling these developers to have the
    best the best of both worlds they can
    modularize their packages have a very
    efficient ci binary management and
    whenever they need to be working on say
    or on more than one packets at the time
    then they can do it it takes a couple of
    clicks and knowing a little bit this is
    document this is not documented yet this
    is this is very new stuff and this will
    be the the feature of uh the future of
    kona conan to zero will implement this
    uh
    as the default
    okay
    this all of this works because of the
    new layout and cmake layout that i was
    showing you earlier in the recipes
    okay
    um
    [Music]
    good
    then i will i will finish my
    presentation today showing another
    another interesting advanced example
    which is cross building with the beetle
    and host profile
    earlier i was cross building 200
    okay and this was a relatively easy
    cross build now i am going to put a more
    challenging example which is the
    protobuf1
    let’s say and this is a simplification
    but this is real the protovat example
    has has this case we have the protobuf
    1.0 package and inside this package we
    have two things
    we have a library a static library
    protocol.leave for example that contains
    most of the logic
    and we also have a protoc executable
    that is used to generate code
    it’s a code generator that needs to be
    used at build time okay and this is
    challenging let me show you how it works
    let’s let’s say that we want to build a
    an atm server package
    okay for the atm
    machine that we were talking earlier
    and this this server here is going to
    communicate with protopath
    so it’s very clear that this atm server
    package will need to require the
    protobus package
    okay
    and it needs to do this build
    with this profile with the 32-bits
    architecture compiler is visualized to
    your 15 and the
    and the static runtime both the atm
    server one zero and the protobuf one
    zero containing the static library they
    need to be built with these sx settings
    otherwise they will produce link errors
    but at the same time
    while building atm server
    i need to be calling protoc
    this is a very common scenario because i
    i’m going to generate some
    source code some zip source code some
    from some proto
    file that has a declaration of the
    interfaces
    the protoc package that i’m running here
    is running in the build context
    the build context is the is the place
    where i’m running the build which is my
    computer my computer is a 64 bits
    architecture is a visual studio 16 is
    using their runtime
    while the host context which is the this
    is the gnu
    naming by the way the build context is
    my machine when i’m doing the build the
    host context is the place where the
    application is run
    in this case the atm machine
    okay so we have these two contexts and
    now we have two profiles we have the the
    windows pc profile and we have the atm
    model 1 profile
    this is way more evident if we do a full
    cross building and this also works the
    same way
    we could be
    cross building for example from windows
    to a linux
    machine here and then the the build
    context and the build profile will be
    windows
    pc
    and the host context and the host
    profile here will be a linux
    context that means that this protovat
    1.0 containing the library should be a
    linux binary a linux library and the
    prototype 1.0 here in my build machine
    should be a windows binary containing
    the protoc
    executable
    okay so this is what has been built
    into conan
    let me show you
    this example code here
    here we have the two profiles this is my
    my windows profile
    okay this is my my current build machine
    and this one is the profile for the 32
    bits architecture which is the host
    machine which is the atm server
    the protobuf package here
    is a standard one is it contains
    a protobuf proxy which is printing some
    messages
    and a protoc proxy which is also
    printing some other messages okay this
    is not where the important stuff is
    the important stuff is in the atm server
    package
    and this is
    the point
    we are going to use
    both are requires an appeal requires to
    protobuf
    this requires is a requirement of a
    library it’s a request for the host
    context
    okay it’s it will depend it will link
    with the protovat
    library the build requires
    is a required for the build context this
    will bring the prototype in my windows
    build context
    to be able to run the protoc
    executable
    here we can see that the build method of
    the atm server recipe it contains a call
    to the protoc
    this protoc that is running here
    will be the protoc inside the bill
    requires
    and as such it should be run with the
    configuration of the bill requires
    and
    this is
    basically
    let’s
    do a conan
    export prototype
    to be sort of
    here protobuf 1.0
    and now let’s move to the atm server
    and let’s do a conan create so in the
    same way we specified previously an
    android profile now we can explicitly
    provide the two profiles i’m going to
    specify that my build profile is my
    windows pc
    and my host profile
    and
    is this atm
    this atm
    profile
    and i’m also do okay let’s this is going
    to fail
    okay because i didn’t create
    the protobuf binaries yet
    the amazing thing is that i’m going to
    build
    with the dust that’s built missing
    what i’m going to force now is i’m going
    to do a build
    of protobuf in two different flavors in
    the same build if i was doing cross
    building this will first build protobuf
    executable for windows in a windows
    build and then it will build protovat
    in linux in a cross build build okay
    let’s give it a couple of seconds so the
    output stabilizes and then i will go
    through the
    through the output
    okay this building portable now
    okay come on windows you can do it
    okay now we started to to build the atm
    server
    package
    building it from sources
    and finally it will start testing the
    package
    in any moment
    okay let’s finish now
    ah
    see making windows is so painfully slow
    okay
    it work let me let me
    go through the output
    and i will explain first we can see here
    that we have the two profiles we have
    the host profile
    which is the 32 bits atm
    context and we have the build profile
    which is the 64 bits mybill machine
    if we check here the requirements
    of this of this bill we can see that we
    have two different protobuf flavors we
    have two different package ids we have
    this one
    which is the host one
    okay and we have a different package id
    a different binary which is the build
    required one
    okay now
    conan as i didn’t build protobuf before
    in the in a typical case okay this
    protobuf will be already built in
    artifactory for the two flavors okay but
    i wanted to show the power of conan that
    you can do two different builds of the
    same thing in the same
    in the same launch
    first it is going to build protobuf for
    the build context it is running protobuf
    not very relevant here
    then it will be running again protobuf
    for the for the host context for the
    other configuration
    two different builds two different
    binaries of exactly the same package
    and here is where the important stuff
    starts
    the atm server it starts to build
    it starts to build it calls the build
    method the ability that was calling
    protoc
    if you recall proceed
    okay
    it’s using protobuf and here we can see
    that this is using the protoc executable
    which is 64 bits
    this version here in 1929 for those of
    you don’t know it is 16
    okay so this is running proceed in my
    build context
    and then this is running this is
    creating the atm server package
    and finally when it is testing the atm
    server package it will run in an
    executable and this is the output of
    running this executable we can see that
    when the atm server is running
    is using proto protofat package but is
    using the
    32 bits architecture package
    and is using also visual studio 1916
    for you if you don’t know it is visual
    studio 15
    15 1. and of course this is also a
    statically linked runtime
    executable
    so this is
    what i wanted to
    show you let’s do a brief recap
    using build and host profile will be the
    defaulting to zero at the moment this is
    an opt-in feature if you don’t specify
    the build profile
    it is using the the
    previous way all of these of the build
    context and the host context will not be
    there
    okay it’s an opt-in feature but it’s
    really recommended that you start to use
    it now if you are doing cross-building
    because this will be what will remain
    uh in conan two zero
    the new tools that i’ve been presenting
    earlier like cmx toolchain already used
    this model if you plan to do any cross
    building with the new tool chains
    then you need to use the two profiles
    this is already been still experimental
    but it’s using being in production there
    are companies out there using this this
    cross building approach and we are using
    already ourselves in quantum center for
    cross building the osx new m1
    architectures we are using this approach
    as well
    if you are using in your cross build the
    legacy os build and article settings
    uh please don’t do it anymore try to
    move this way because this will be
    removed in connect to zero and finally i
    wanted to
    um
    to highlight
    that this
    is not easy to do with cement the way
    that we can mix cross-building binaries
    for different contexts
    i can guarantee you this could be a
    really nightmare to do it natively in
    siemens
    okay so thanks very much for
    for being there and listening i wanted
    to give you a few hints
    you have the source code for today’s
    presentation in this url
    if you have any question you want to
    know something more about conan of
    course for questions the first resource
    in github go to connect.io and from
    there you can navigate to all those
    resources github for questions
    and support the documentation have a
    look because the recommendation is
    extensive and we are always trying to
    improve it the blog
    content center for for getting which
    packages are already available for the
    community there is a very good training
    course hands-on and free in the jfoc
    academy as well
    and
    finally the communities both in the
    include cpp discord and in the slack
    channel
    the community is amazing they are really
    helpful they they help each other they
    respond questions there so it’s a it’s a
    great community there
    to finish um yeah the video link
    sorry this hasn’t applied
    please go to this url or this qr qr code
    and rate my talk if you especially for
    the people that are online the first 25
    people
    who enter and and rate my talk they will
    get a free conan t-shirt delivered to
    your home okay so for the people there
    on site you already got your t-shirts
    but if for the people online if you want
    a t-shirt please fill the the the survey
    here
    and we will send you a teaser
    and
    finally thank you very much and if you
    have any questions i i’d love to
    respond
    thanks thanks dave can you hear me
    yeah yeah i can hear you right okay nice
    thanks
    everyone
    i don’t hear you now marco sorry
    you need to get closer to that yeah i
    don’t hear you
    oh wow okay
    it’s a technical issue
    [Music]
    can you hear me now or not yeah i can
    hear you now okay okay now i was saying
    that everyone is still awake so i think
    the presentations
    yeah it was space but i i wanted to to
    show these the new things
    so
    yeah if you want to follow up don’t
    hesitate to to ping me later
    we can talk i’m also pretty available in
    in the slack and other channels so feel
    free to contact me later thanks thanks
    and i think we have one question here
    right uh marco you have a question okay
    so i trust you
    my microphone
    uh no i am afraid that that might that
    mick is not
    it’s not working you need to get closer
    to the laptop yeah talk to the laptop
    please
    can you hear me now
    yeah great
    okay and i already have a sonar tape
    nexus repository in place is there a way
    to store current packages on this kind
    of repository instead of the factory
    yeah that’s a good question
    so uh
    some major players including nexus
    sonotype and gitlab
    and also there is something that like
    was clouded or something they provide
    support for quantum packages so in case
    of nexus
    there is a
    there is a conan plugin so you might
    need to install the plugin
    uh and yeah please please try it what i
    can say and from my experience and the
    feedback that i get from from conan
    issues in the github repo
    is that the integration is not as solid
    so as the artifactory communication is
    free if you try the nexus if it goes
    fine for you then then great happy to
    know it
    and but if you experience any issue give
    a try to the artifactory c because the
    integration might might be better
    okay thank you very much
    yeah you’re welcome
    other questions
    here in the
    here in the room
    anyone uh let me check youtube i think
    we don’t have questions on youtube
    either so
    let me check again
    oh we don’t we don’t have questions yet
    okay okay yeah we don’t have we don’t
    have on youtube we don’t have one slack
    we are basically connected to
    three channels at the moment we have
    physical channel here with people
    attending we have slack we have youtube
    maybe someone from the from the social
    networks as well
    by the way other other questions guys no
    no question sir
    i know you want to go to for the pizza
    that’s why you don’t have questions
    that’s a that’s a strategy for going to
    to the pizzeria
    i want some pizza too please deliver
    some
    i i can i can send you some pictures of
    our pizzas
    please
    no that’s that’s that’s right and uh
    okay i think diego i think that’s all
    because if if people don’t have other
    questions i think
    you we can set you free and uh
    thanks again for uh for the session and
    also thanks to jfrock for all the
    gadgets for the t-shirts and
    the all the the tiny the tiny frogs
    are here and uh
    i hope to meet you again to see you
    again in person hopefully next year
    because
    i’m confident for next year maybe
    we’ll have that that conference in rome
    that we had to cancel two years ago
    and
    i hope to have you maybe there
    speaking again about conan
    about the the other features that you’re
    going to add to this great
    package manager
    and
    so great
    i think folks you can make again some
    noise
    thank you very much
    thank you thank you for inviting thank
    you very much and my pleasure
    hope to see you soon
    to you for the t-shirt and
    so see you next time next month we have
    another session about cross-platform
    development from a guy from pink cell so
    thanks again diego thanks everyone for
    attending we go for the pizza now you
    can stay with us on slack as usual
    italiancpp.org for getting access to the
    channel uh see you next month thank you
    thank you bye
    thank you bye