Undefined reference to ‘CV:: imread (CV:: String const & int)’

Modify the cmakelist file as follows:

cmake_minimum_required(VERSION 3.17)
project(untitled)

set(CMAKE_CXX_STANDARD 14)
find_package( OpenCV REQUIRED )

include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(untitled main.cpp)
target_link_libraries(untitled ${OpenCV_LIBS} )

Read More: