1

For a project, I`m using the MLX90641 IR camera, and I using the following GitHub project:

mlx90641-library adapted for Raspberry Pi

In this project have a Makefile with the executable:

    # Makefile for examples
    LIBS=-lm -lbcm2835
    EX_DIR=Examples/

    printgrid: $(EX_DIR)print_grid.cpp 
    $(CXX) -IHeaders/ MLX90641_API.cpp MLX90641_I2C_Driver.cpp $< -o $@  $(LIBS)

As documented in the GitHub project, by running: sudo ./printgrid we run print_grid.cpp file of the GitLab project. But I want to include the executable into my already build CMakeList.txt file. I have made the following CMakeList.txt:

    cmake_minimum_required(VERSION 3.10)

    set(CMAKE_CXX_STANDARD 20)

    project(robot-on-wheels)

    # Find packages for build #
    find_package( PahoMqttCpp REQUIRED)
    find_package( Threads REQUIRED )

    # MAIN CPP FILE TO RUN #
    add_executable(robot main.cpp)

    # Enable the example code for the MLX90641 IR camera #
    add_executable(camera MLX90641/Examples/print_grid.cpp)

    # Add files to Lib for the motorcontroller #
    add_library(motorcontroller
                Motor/Headers/BV4604_MotorControl.h
                Motor/BV4604_MotorControl.cpp
                Motor/Sonar.cpp
                Motor/Headers/Sonar.h
                )

    # Add files to libray for the MLX90641 #
    add_library(mlx90641_lib
                MLX90641/MLX90641_API.cpp
                MLX90641/MLX90641_I2C_Driver.cpp
                MLX90641/Headers/MLX90641_API.h
                MLX90641/Headers/MLX90641_I2C_Driver.h
                )

    # MQTT #
    target_link_libraries(robot ${PahoMqttCpp_LIB} -lpaho-mqttpp3 -lpaho-mqtt3as)
    # Motorcontroller #
    target_link_libraries(robot motorcontroller)

    # MLX90641 #
    target_link_libraries(robot mlx90641_lib)
    # Enable the example code for the MLX90641 IR camera #
    target_link_libraries(camera mlx90641_lib)

    # Thread #
    target_link_libraries(robot ${CMAKE_THREAD_LIBS_INIT})

    # Wiring Pi #
    add_definitions(-I/usr/include -L/usr/lib -lwiringPi)

    target_link_libraries(robot wiringPi)
    # Enable the example code for the MLX90641 IR camera #
    target_link_libraries(camera wiringPi)

But when I run the executable via CLion I get te following:

CLion CMake build

So i`m wondering if somebody could help me out with fixing my CMakeList.txt file. I think is has something to do with the BCM2835 library I had to instal:

g++ -IHeaders/ MLX90641_API.cpp MLX90641_I2C_Driver.cpp Examples/print_grid.cpp -o printgrid -lm -lbcm2835

Overview Clion and folders

OKE I GOT IT FIXED

This got it all setup. Beside this, i needed to run it with sudo

cmake_minimum_required(VERSION 3.10)

set(CMAKE_CXX_STANDARD 20)

project(robot-on-wheels)

add_executable(camera_example MLX90641/Examples/print_grid.cpp)

add_library(mlx90641
        MLX90641/MLX90641_API.cpp
        MLX90641/MLX90641_I2C_Driver.cpp)

target_link_libraries(mlx90641 -lm)

target_link_libraries(camera_example
        mlx90641
        -lbcm2835)
Stefan de Kraker
  • 101
  • 2
  • 11
  • Please, add **textual** representation of the build output, not the *image* of it. This is a requirement of Stack Overflow, see also [ask]. – Tsyvarev Dec 17 '20 at 12:29
  • Try to add `-lbcm2835` to the list of linked libraries like this: `add_definitions(-I/usr/include -L/usr/lib -lwiringPi -lbcm2835)`. Also add `set(CMAKE_VERBOSE_MAKEFILE ON)` in the beginning of your `CMakeList.txt` file so you can get a verbose build output and add it to your question. – PolarBear Dec 17 '20 at 12:38

0 Answers0