Set Opencv path for a c++ project using Cmake

后端 未结 3 1259
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 17:24

I have two Opencvs, opencv-2.4.10 is installed in /usr and opencv-3.1 is installed in /usr/local. I can set the opencv path in Eclipse easily. In cmake, how can I set the path f

3条回答
  •  醉梦人生
    2021-02-15 18:07

    None of the other answers worked for me (linux, opencv 4.0.0, haven't tested yet with opencv 3.x.x).

    Adding the following before the line find_package(...) in the CMakeLists.txt worked:

    set(OpenCV_DIR /path/to/opencv_install_dir/lib/cmake/opencv4)
    

    If opencv was compiled from source with a none standard installation target directory, then /path/to/opencv_install_dir is (should be) known, otherwise search for the location of the directory structure lib/cmake/opencv*.

提交回复
热议问题