Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking openCV to clion project

I am a newbie with clion and I want to compile my project.

If I compile it in the console: g++ -o a main.cpp -std=c++11 pkg-config opencv --cflags --libs -lboost_system ... it works fine.

When I add it to Cmake/Cache --> CMAKE_CXX_FLAGS, it will be parsed to "pkg-config opencv --cflags --libs" what is not wanted.

Can somebody help me?

like image 417
j35t3r Avatar asked Dec 02 '25 00:12

j35t3r


1 Answers

1. From the command line

You could set CMAKE_CXX_FLAGS: export CMAKE_CXX_FLAGS=`pkg-config opencv --cflags --libs` (notice the back ticks)

2. Inside the CMakeLists.txt file/your cmake file:

If you are using OpenCV 2.4 or later, then you could do it using just:

FIND_PACKAGE( OpenCV REQUIRED core highgui imgproc)

Other way would be:

find_package(PkgConfig REQUIRED)
pkg_search_module(OpenCV REQUIRED core highgui imgproc)

(Add/subtract other OpenCV modules too as required by your project)

like image 173
PraveenPalanisamy Avatar answered Dec 03 '25 13:12

PraveenPalanisamy