Skip to content
Snippets Groups Projects
Select Git revision
  • main
1 result

shared_test

  • Shared test

    The current project aims to show how to create packages with shared libraries.

    In addition, it is shown how to use these packages in editable mode using conan.

    Project architecture

    The project is composed of 4 components:

    • the lib_b and lib_c that are shared libraries and does not depend on any other library.
    • the lib_a that depends on lib_b and lib_c.
    • the app that depends on lib_a.
    graph TD
        lib_b --> lib_a
        lib_c --> lib_a
        lib_a --> app

    Basic usage

    The basic usage consist on creating each package and building the app. To do that, you can use the following command:

    ./create_and_use.sh

    Note: We had to create each package manually because there are not uploaded into the conan's remote. But in real life, you can use the conan's remote to download the packages.

    Editable mode aka development mode

    When you are developing a package, you may want to use the package in an editable mode. This means that you can change the package and the changes will be reflected in the app without the need to package the library again. Conan has a convenient feature that allows you to do that (in some cases without changing anything).

    To use the packages in an editable mode, you can use the following command:

    ./editable_and_use.sh

    This command will build lib_b and lib_c locally and register them in conan as editable packages. Then, it will package lib_a and finally, it will build the app.

    After a first run, we notice that the lib_c show incorrect message (it's in french!). The script will fix the message and rebuild the lib_c and run the app again.

    Note: A second script name editable_and_use_v2.sh is available. It shows a different way to use the editable mode that ignore the lib dependencies order and that automatically rebuild any package that has been changed.