无法使用CMake Visual Studio 12构建OpenCV项目

时间:2015-04-03 12:35:21

标签: opencv visual-studio-2012 cmake

我正在尝试使用CMake GUI构建基于OpenCV的项目,但不断收到错误。我跟着this线程,但仍然无法解决我的问题。

以下是我在GUI中收到的消息(以及错误):

CMake Warning at C:/SCCH/libs/opencv249_x86_3/OpenCVConfig.cmake:161 (message): 
Found OpenCV Windows Pack but it has not binaries compatible with your
configuration.

You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.

Call Stack (most recent call first):
  CMakeLists.txt:9 (FIND_PACKAGE)

CMake Error at CMakeLists.txt:9 (FIND_PACKAGE):
  Found package configuration file:

     C:/SCCH/libs/opencv249_x86_3/OpenCVConfig.cmake
  but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to  be NOT FOUND.

我正在使用使用CMake的TBB库构建的OpenCV 2.49(x86),并针对Visual Studio 2013(版本12)。另外,我为OpenCV定义了一个系统变量。并且,以下是我用于构建的CMakeLists.txt文件(我收到上述错误)项目解决方案(.sln)文件:

cmake_minimum_required(VERSION 2.8)

project(FlexTex)

SET(OpenCV_DIR "C:/SCCH/libs/opencv249_x86_3")
FIND_PACKAGE(OpenCV REQUIRED)

SET(FLEX_TEX_DLL_FILES ./LibFlexTexDLL/inc/FlexTexDLL.h ./LibFlexTexDLL/src/FlexTexDLL.cpp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/LibFlexTexDLL/inc/)
ADD_LIBRARY(FlexTexDLL SHARED ${FLEX_TEX_DLL_FILES})
TARGET_LINK_LIBRARIES(FlexTexDLL ${OpenCV_LIBS})

SET(FLEX_TEX_PP_DLL_FILES ./LibFlexTexPPDLL/inc/defines.h ./LibFlexTexPPDLL/inc/FlexTexPPDLL.h ./LibFlexTexPPDLL/inc/FlexTexPPImpl.h   ./LibFlexTexPPDLL/src/FlexTexPPDLL.cpp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/LibFlexTexPPDLL/inc/)
ADD_LIBRARY(FlexTexPPDLL SHARED ${FLEX_TEX_PP_DLL_FILES})
TARGET_LINK_LIBRARIES(FlexTexPPDLL ${OpenCV_LIBS})

ADD_EXECUTABLE (FlexTexMain FlexTexMain/src/FlexTexMain.cpp )
TARGET_LINK_LIBRARIES(FlexTexMain FlexTexPPDLL )

1 个答案:

答案 0 :(得分:0)

似乎您尝试使用vs2013(版本12)构建应用程序,但是您已经为版本vs2012(版本11)构建了OpenCV分发版。这就是问题所在。

您可以尝试使用Creemple分发:http://opencv.org/ceemple-opencv-distribution-for-visual-studio.html