Skip to content

yushulx/cmake-cpp-barcode-qrcode-mrz

Repository files navigation

Building 1D/2D Barcode Reader with C++ and CMake

This repository contains examples demonstrating how to utilize the Dynamsoft Barcode Reader SDK to build barcode and QR code detection applications with C++ and CMake on Windows, Linux, macOS, and Raspberry Pi.

Prerequisites

  • Obtain a 30-day free trial license for Dynamsoft Barcode Reader. Update the following code in main.cxx:

    DBR_InitLicense(license, errorMsgBuffer, 512);
  • OpenCV Installation

    1. Download OpenCV

    2. Configure the environment variable OpenCV_DIR to the path of the OpenCV installation directory.

    3. Add the following lines to the CMakeLists.txt file:

      # Find OpenCV, you may need to set OpenCV_DIR variable
      # to the absolute path to the directory containing OpenCVConfig.cmake file
      # via the command line or GUI
      find_package(OpenCV REQUIRED)

Supported Platforms

  • Windows x64
  • Linux x64/ARM64/ARM32
  • macOS x64 (Intel/Apple Silicon)

How to Build a CMake Project

Windows

  1. Create a build folder:

    mkdir build
    cd build
  2. Configure and build the project:

    # x86
    cmake -DCMAKE_GENERATOR_PLATFORM=x86 ..
    
    # x64
    cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
    
    cmake --build . --config release

    For MinGW:

    cmake -G "MinGW Makefiles" ..

Linux and Raspberry Pi OS

  1. Install CMake:

    sudo apt-get install cmake
  2. Create a build folder:

    mkdir build
    cd build
  3. Configure and build the project:

    cmake ..
    cmake --build . --config release 

macOS

  1. Install CMake:

    brew install cmake
  2. Create a build folder:

    mkdir build
    cd build
  3. Configure and build the project:

    cmake ..
    cmake --build . --config release 

Examples

Blog