OpenCV_FOUND to FALSE so package “OpenCV” is consi

2019-04-10 22:19发布

I am having problems at the moment trying to get my cmake to see my opencv. I have installed opencv and can run the some of the sample problems and some give the same error as the the error I get in my cmake file (when running the sample programs through terminal)

I have tried to change the environment variable path as described in http://answers.opencv.org/question/35125/cmake-linking-error-opencv_found-to-false-ubuntu/

My bashrc file now looks like

CMAKE_PREFIX_PATH=/home/durham/Desktop/OpenCV/opencv-2.4.9:$CMAKE_PREFIX_PATH

CPATH=/home/durham/Desktop/OpenCV/opencv-2.4.9/include:$CPATH LD_LIBRARY_PATH=/home/durham/Desktop/OpenCV/opencv-2.4.9/lib:$LD_LIBRARY_PATH PATH=/home/durham/Desktop/OpenCV/opencv-2.4.9bin:$PATH

PKG_CONFIG_PATH=/home/durham/Desktop/OpenCV/opencv-2.4.9/lib/pkgconfig:$PKG_CONFIG_PATH

PYTHONPATH=/home/durham/Desktop/OpenCV/opencv-2.4.9/lib/python2.7/dist-packages:$PYTHONPATH

and the contents of /etc/ld.so.conf are

include /etc/ld.so.conf.d/*.conf 
include /home/durham/Desktop/OpenCV/opencv-2.4.9

The cmake file I am trying to run looks like this

cmake_minimum_required(VERSION 2.6)

if(POLICY CMP0020)   cmake_policy(SET CMP0020 NEW) endif(POLICY CMP0020)

SET(CMAKE_VERBOSE_MAKEFILE TRUE)  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/config)

ADD_DEFINITIONS(-DQT_THREAD_SUPPORT -D_REENTRANT -DQT_NO_DEBUG
-DIQRMODULE)

SET(QT_MT_REQUIRED TRUE) find_package(Qt5Widgets) FIND_PACKAGE(OpenCV REQUIRED)


IF(NOT DEFINED IQR_INCLUDE_DIR)   set (IQR_INCLUDE_DIR "/usr/include/iqr") #default for linux ENDIF(NOT DEFINED IQR_INCLUDE_DIR)

IF(NOT EXISTS ${IQR_INCLUDE_DIR})   message(STATUS "not exists IQR_INCLUDE_DIR: ${IQR_INCLUDE_DIR}")   set (IQR_INCLUDE_DIR $ENV{IQR_INCLUDE_DIR} CACHE PATH "" FORCE)   IF(NOT EXISTS ${IQR_INCLUDE_DIR})
    message(STATUS "IQR_INCLUDE_DIR set to ${IQR_INCLUDE_DIR}")
    message(FATAL_ERROR "Please specify iqr include directory using IQR_INCLUDE_DIR env. variable")   ENDIF(NOT EXISTS ${IQR_INCLUDE_DIR}) ENDIF(NOT EXISTS ${IQR_INCLUDE_DIR})

IF(WIN32)   IF(NOT DEFINED IQR_LIB_DIR)
    set (IQR_LIB_DIR $ENV{IQR_LIB_DIR} CACHE PATH "" FORCE)   ENDIF(NOT DEFINED IQR_LIB_DIR)

  IF(NOT EXISTS ${IQR_LIB_DIR})
    message(FATAL_ERROR "Please specify phidgets include directory using IQR_LIB_DIR env. variable")   ENDIF(NOT EXISTS ${IQR_LIB_DIR}) ENDIF(WIN32)




SET(libSrc
    moduleArDroneBottomCamera.cpp
    )

INCLUDE_directories(   ${CMAKE_CURRENT_SOURCE_DIR}    ${IQR_INCLUDE_DIR}   ${QT_INCLUDE_DIR}   ${OPENCV_INCLUDE_DIR}   ardrone_sdk/   ardrone_sdk/VP_SDK/   ardrone_sdk/VLIB/Stages/   ardrone_sdk/VP_SDK/VP_Os/   ardrone_sdk/VP_SDK/VP_Os/linux/   ardrone_sdk/VP_SDK/VP_Stages/ )

ADD_SUBDIRECTORY(ardrone_sdk)

ADD_LIBRARY(moduleArDroneBottomCamera SHARED ${libSrc})

IF(WIN32)   set(IQR_LIBS "${IQR_LIB_DIR}/libIqrItem.dll") ENDIF(WIN32)


TARGET_LINK_LIBRARIES (moduleArDroneBottomCamera   ${OPENCV_LIBRARIES} pc_ardrone   ${QT_LIBRARIES}   ${IQR_LIBS}   )

qt5_use_modules(moduleArDroneBottomCamera Core Widgets Network)


SET_TARGET_PROPERTIES(moduleArDroneBottomCamera PROPERTIES PREFIX "")

IF(UNIX)   set (IQR_INSTALL_DIR $ENV{HOME}) ENDIF(UNIX)

IF(WIN32)   set (IQR_INSTALL_DIR $ENV{USERPROFILE}) ENDIF(WIN32)


INSTALL(TARGETS moduleArDroneBottomCamera    LIBRARY DESTINATION ${IQR_INSTALL_DIR}/iqr/lib/Modules    RUNTIME DESTINATION ${IQR_INSTALL_DIR}/iqr/lib/Modules )

But when I try to generate this using the cmake gui I get the following output (cant post images yet so its in the link)

http://postimg.org/image/4e553z6rh/

I am running Ubuntu 14.04. Any suggestions?

Thanks D

1条回答
神经病院院长
2楼-- · 2019-04-10 23:03

Fast and dirty solution: try to install opencv (You know, make && sudo make install). After installation header files should be inc /usr/local/include and library files should be in /usr/local/lib .

The problem might lay somewhere ind FindOpenCV.cmake file, so You might as well try to understand what it is doing and maybe fix it - CMake syntax is fairly straightforward. It might check in a default instalation location instead where it lies right now, or some rarely used environment variable.

查看更多
登录 后发表回答