CMake VS2017 C ++ - 无法打开文件opencv_world.lib

时间:2017-12-19 00:29:23

标签: c++ visual-studio opencv cmake

我正在开发一个项目,我想添加OpenCV。 我下载了预构建的opencv 3.3.1库和最新版本的cmake。 此外,我在x64调试模式的Windows x64操作系统上使用Visual Studios 2017。

CMake可以毫无错误地构建所有内容。 但是,当我想在VS或调试中构建我的项目时, 我收到一个致命的链接错误:

  

致命错误LNK1104:无法打开文件'C:\ OpenCV 3.3.1 \ opencv \ build \ lib \ Debug \ opencv_world331d.lib'

所以我检查了lib文件的目录。 但目录和lib文件都不存在。

我在我的CMakeLists.txt下方附上:

SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}" )
FIND_PACKAGE( KinectSDK2 REQUIRED )
INCLUDE_DIRECTORIES( ${KinectSDK2_INCLUDE_DIRS} )
LINK_DIRECTORIES( ${KinectSDK2_LIBRARY_DIRS} ) 
SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}" )
FIND_PACKAGE( PCL 1.8.1 REQUIRED )
INCLUDE_DIRECTORIES( ${PCL_INCLUDE_DIRS} )
LINK_DIRECTORIES( ${PCL_LIBRARY_DIRS} )
FIND_PACKAGE( OpenCV REQUIRED )
INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} )
LINK_DIRECTORIES( ${OpenCV_LIBRARY_DIRS} )
MESSAGE(STATUS "OpenCV library status:")
MESSAGE(STATUS "    version: ${OpenCV_VERSION}")
MESSAGE(STATUS "    libraries: ${OpenCV_LIBS}")
MESSAGE(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
FILE( GLOB DesiredView_SRC
    "*.h"
    "*.cpp"
)
ADD_EXECUTABLE( DesiredView ${DesiredView_SRC} )

TARGET_LINK_LIBRARIES( DesiredView ${PCL_LIBRARIES} ${KinectSDK2_LIBRARIES} ${OpenCV_LIBS} )

我刚开始与CMake合作2天前。 所以我对此很新。

我非常感谢任何帮助。

弗洛里安

1 个答案:

答案 0 :(得分:0)

感谢您的回答。不过我必须在这里发布。 这是message()代码。

  

OpenCV库状态:       版本:3.3.1       库:opencv_calib3d; opencv_core; opencv_cudaarithm; opencv_cudabgsegm; opencv_cudacodec; opencv_cudafeatures2d; opencv_cudafilters; opencv_cudaimgproc; opencv_cudaobjdetect; opencv_cudaoptflow; opencv_cudastereo; opencv_cudawarping; opencv_dnn; opencv_features2d; opencv_flann; opencv_highgui; opencv_imgcodecs; opencv_imgproc; opencv_ml; opencv_objdetect; opencv_photo; opencv_shape; opencv_stitching; opencv_superres; opencv_video; opencv_videoio; opencv_videostab; opencv_world       include path:C:/ OpenCV 3.3.1 / opencv / build; C:/ OpenCV 3.3.1 / opencv / sources / include; C:/ OpenCV 3.3.1 / opencv / sources / include / opencv; C:/ OpenCV 3.3 .1 / opencv / sources / modules / core / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudaarithm / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / flann / include; C :/ OpenCV 3.3.1 / opencv / sources / modules / imgproc / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / ml / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / objdetect / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / video / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudabgsegm / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudafilters / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudaimgproc / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudawarping / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / dnn / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / imgcodecs / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / photo / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / shape / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / videoi o / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudacodec / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudaobjdetect / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudaoptflow / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / highgui / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / superres / include; C:/ OpenCV 3.3。 1 / opencv / sources / modules / features2d / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / calib3d / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / cudafeatures2d / include; C: / OpenCV 3.3.1 / opencv / sources / modules / cudastereo / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / stitching / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / videostab / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / world / include; C:/ OpenCV 3.3.1 / opencv / sources / modules / ts / include

我的构建和源文件夹位于此处:

  

C:\ OpenCV 3.3.1 \ opencv

感谢:)