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:
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
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)