我试图在ubuntu 16.04上使用OpenCV 2.4编译项目。我使用apt-get:
安装了opencvsudo apt-get install libopencv-dev
sudo apt-get install libopencv-nonfree-dev
但是,在编译项目时,我收到以下错误消息:
undefined reference to `cv::imread(std::string const&, int)'
我的CMakeLists.txt
看起来像这样:
cmake_minimum_required(VERSION 3.5)
project(Ex)
find_package(OpenCV REQUIRED )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c99")
message(STATUS "CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}}")
message(STATUS "OpenCV_LIBS=${OpenCV_LIBS}")
set(SOURCE_FILES main.cpp)
add_executable(Ex ${SOURCE_FILES})
target_link_libraries(Ex ${OpenCV_LIBS})
set_property(TARGET Ex PROPERTY C_STANDARD 99)
有谁知道如何解决这个问题?
修改
第二条消息的输出是
OpenCV_LIBS=opencv_videostab;opencv_video;opencv_ts;opencv_superres;opencv_stitching;opencv_photo;opencv_ocl;opencv_objdetect;opencv_nonfree;opencv_ml;opencv_legacy;opencv_imgproc;opencv_highgui;opencv_gpu;opencv_flann;opencv_features2d;opencv_core;opencv_contrib;opencv_calib3d