Opencv cmake error

Hello,I have installed opencv3.4.7 on Ubuntu18.04 and I can get its version by using pkg-config --modversion opencv ,but my cmake have Error,I will show it , I’d appreciate it if anyone could help me.
Error:

CMake Error at CMakeLists.txt:12 (add_executable):
  Target "untitled1" links to target "Eigen3::Eigen" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

My Cmakelist:

cmake_minimum_required(VERSION 3.20)
project(untitled1)


set(CMAKE_CXX_STANDARD 14)


set(OpenCV_DIR "/home/ma/RM/opencv/opencv-3.4.7/build")
find_package(OpenCV REQUIRED)

add_executable(untitled1 main.cpp)

message(STATUS "opencv: ${OpenCV_LIBS}")
target_link_libraries(untitled1 ${OpenCV_LIBS} )

how exactly did you do that ?
do you have Eigen installed ?

can you put that before the

add_executable(untitled1 main.cpp)

line ? what does it print ?

I intsall it follow the step on the Internet,First install some dependency packages and then camke and make.
I have installed eigen and I can get it version in terminal

I have done that ,the print is
opencv: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_viz

does your code use Eigen ?

hahaha, good one … :wink:

No, my code only hava a “hello world” :disappointed:

1 Like