CMake include OpenCV on ArchLinux
Hi,
When I want to compile my project, I get the following error message:
undefined reference to `cv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >&, double, int, int, cv::Size_<int>, cv::Size_<int>)'
My problem is that there is no entry for opencv as found sometimes on stackoverlow.com
Can anybody tell me, how to include the OpenCV library?
请先登录再写评论。
Hi Peter.
You need to set up your CMakeLists.txt to link with OpenCV. Please see the article: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html.
Hi Anna,
thanks for your answer, but it is still not working for me. Still having error messages: like this: undefined reference to `cv::getRotationMatrix2D(cv::Point_<float>, double, double)'
can anybody tell me, if I use the right libraries?
my cmake file looks now like this:
Could you please show how you've linked OpenCV in your CMakeLists.txt?
cmake_minimum_required(VERSION 3.3)
project(cli)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(OpenCV REQUIRED)
#target_link_libraries(cli ${OpenCV_LIBS}) # replace binary_name
#set(OpenCV_FOUND 1)
set(SOURCE_FILES
include/A_WowbaggerChoice.h
include/AbstractChoice.h
include/B_RocChoice.h
include/C_CnnChoice.h
include/D_DetectorChoice.h
include/E_LearningChoice.h
include/Help.h
include/MyException.h
include/StartScreen.h
include/types.h
src/A_WowbaggerChoice.cpp
src/AbstractChoice.cpp
src/B_RocChoice.cpp
src/C_CnnChoice.cpp
src/D_DetectorChoice.cpp
src/E_LearningChoice.cpp
src/Help.cpp
src/main.cpp
src/MyException.cpp
src/StartScreen.cpp
tinyxml/tinystr.cpp
tinyxml/tinystr.h
tinyxml/tinyxml.cpp)
add_executable(cli ${SOURCE_FILES})
It is solved, I just added one line to my CMake file:
target_link_libraries( cli ${OpenCV_LIBS} )
Source: http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html