Could not find module FindOpenCV.cmake ( Error in configuration process)

前端 未结 12 2238
既然无缘
既然无缘 2020-11-29 02:04

I wrote a CMakeLists.txt for a project in C++, which uses OpenCV libraries. When I try to create the project using cmake, I ge

12条回答
  •  旧时难觅i
    2020-11-29 02:36

    Followed @hugh-pearse 's and @leszek-hanusz 's answers, with a little tweak. I had installed opencv from ubuntu 12.10 repository (libopencv-)* and had the same problem. Couldn't solve it with export OpenCV_DIR=/usr/share/OpenCV/ (since my OpenCVConfig.cmake whas there). It was solved when I also changed some lines on the OpenCVConfig.cmake file:

    # ======================================================
    # Include directories to add to the user project:
    # ======================================================
    
    # Provide the include directories to the caller
    
    #SET(OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include/opencv;${OpenCV_INSTALL_PATH}/include")
    
    SET(OpenCV_INCLUDE_DIRS "/usr/include/opencv;/usr/include/opencv2")
    INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
    
    # ======================================================
    # Link directories to add to the user project:
    # ======================================================
    
    # Provide the libs directory anyway, it may be needed in some cases.
    
    #SET(OpenCV_LIB_DIR "${OpenCV_INSTALL_PATH}/lib")
    
    SET(OpenCV_LIB_DIR "/usr/lib")
    
    LINK_DIRECTORIES(${OpenCV_LIB_DIR})
    

    And that worked on my Ubuntu 12.10. Remember to add the target_link_libraries(yourprojectname ${OpenCV_LIBS}) in your CMakeLists.txt.

提交回复
热议问题