Linking an openCV project to a client
I am a newbie with clion and I want to compile my project.
If I compile it in the console: g ++ -o 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 processed by "pkg-config opencv --cflags --libs", which is unnecessary.
Can anyone help me?
source to share
1. From the command line
You can set CMAKE_CXX_FLAGS
:
export CMAKE_CXX_FLAGS = `pkg-config opencv --cflags -libs` (note the back ticks)
2. Inside the file CMakeLists.txt
/ your cmake file:
If you are using OpenCV 2.4 or newer, you can do this using only:
FIND_PACKAGE( OpenCV REQUIRED core highgui imgproc)
Another way:
find_package(PkgConfig REQUIRED) pkg_search_module(OpenCV REQUIRED core highgui imgproc)
(add / subtract other OpenCV modules also as per your project requirements)
source to share