GithubHelp home page GithubHelp logo

cpp-conan-example's Introduction

cpp-conan-example

A sample project, written in CPP/C++ which uses CMake, Conan and OpenCV to build the opencv-cpp-example app.

This project demonstrates how Conan revolutionized packages/dependencies management in CPP/C++.

WORK-IN-PROGRESS: Currently, I've only tested it on my macOS, though I do intend to add more profiles and configurations so this project will be built cross-platform.

Requirements

Initial Setup

  1. Git clone this project
    git clone https://github.com/unfor19/cpp-conan-example.git
    cd cpp-conan-example
  2. IMPORTANT: From now on, the working dir is the cloned project's root dir
  3. Copy configuration files to ~/.conan/
    cp conan_files/conan.conf conan_files/settings.yml ~/.conan/ && \
    cp conan_files/profiles/* ~/.conan/profiles/
I want to know more - Expand/Collapse

Conan Profiles

I'm using Conan Profiles per operating system and architecture.

Profiles allows users to set a complete configuration set for settings, options, environment variables, and build requirements in a file. Source

Check the conan_files/profiles that I've created to build this project.

settings.yml

The input settings for packages in Conan are predefined in ~/.conan/settings.yml file, so only a few like os or compiler are possible. These are the default values, but it is possible to customize them, see Customizing settings. Source

I customized this file by adding the value 13.1 to compiler.apple-clang.version.

Remote registry

We'll use conancenter as the default remote registry to fetch dependencies, that is why I haven't added it.

macOS

  1. OS: Monterey
  2. Xcode 13.3+ - includes apple-clang 13.1.6

Getting Started

  1. Install dependencies
    • macOS
      conan install ./conan_files  \
          --install-folder ./build \
          -pr:b macos \
          --build missing \
          -pr:h macos-requirements 
  2. Build the app
    conan build conan_files --build-folder build --source-folder .
  3. Run the app for the first time to allow camera usage
    1. Terminal > Run the app by executing

      # macOS/Linux/WSL2
      ./build/bin/opencv_example
      # powershell
      .\build\bin\opencv_example
    2. Allow camera access for the first time

    3. Terminate the app in the terminal by hitting CTRL+C

  4. Run the app again as mentioned above and watch yourself, I hope you're smiling
    Built with OpenCV 4.5.5
    Capture is opened
    ^C # Hit CTRL+C

Troubleshooting

  • IDE does not recognize opencv2 as an available library, make sure to add conan local packages to the includePath, in VSCode it's "${HOME}/.conan/**", an example for .vscode/c_cpp_properties.json file:
    {
    "configurations": [
       {
          "name": "Mac",
          "includePath": ["${workspaceFolder}/**", "${HOME}/.conan/**"],
          "defines": [],
          "macFrameworkPath": [],
          "compilerPath": "/usr/bin/clang",
          "cStandard": "gnu17",
          "cppStandard": "gnu++17",
          "intelliSenseMode": "macos-clang-x64"
       }
    ],
    "version": 4
    }

Authors

Created and maintained by Meir Gabay

License

This project is licensed under the MIT License - see the LICENSE file for details

cpp-conan-example's People

Contributors

unfor19 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.