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
Screenshot_20160102_104152.png
Can anybody tell me, how to include the OpenCV library?

5 comments
Comment actions Permalink

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.

0
Comment actions Permalink

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:

0
Comment actions Permalink

Could you please show how you've linked OpenCV in your CMakeLists.txt?

1
Comment actions Permalink

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

0
Comment actions Permalink

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

0

Please sign in to leave a comment.