Mac CLion配置OpenCV4环境

网上例子很多,但尝试很多方法一直报错如下:

dyld: Library not loaded: @rpath/libopencv_xphoto.3.1.dylib
  Referenced from: (省略)
  Reason: image not found

推测可能是mac装了太多版本opencv,无法链接到正确lib库,所以手动指定下OpenCV_DIR即可,修改后的CMakeLists.txt如下:

cmake_minimum_required(VERSION 3.13)
project(tiny)

set(CMAKE_CXX_STANDARD 14)

add_executable(项目名称 cv_test.cpp)

set(OpenCV_DIR "/usr/local/Cellar/opencv/4.1.1_2/lib/cmake/opencv4") # opencvlib地址

find_package(OpenCV REQUIRED)

target_link_libraries(项目名称 ${OpenCV_LIBS})
 

你可能感兴趣的:(cmake,环境配置,opencv,Clion,经验与工具方法)