Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用cmake将OpenCv作为静态库_C++_Opencv_Cmake - Fatal编程技术网

C++ 使用cmake将OpenCv作为静态库

C++ 使用cmake将OpenCv作为静态库,c++,opencv,cmake,C++,Opencv,Cmake,我有一个为项目生成NSVC项目的cmake,它包括共享格式的opencv(使用*.dll) 我想更改cmake,以便它可以链接opencv静态库 我的cmake的简单形式如下: find_package(OpenCV REQUIRED) add_executable(test test.cpp) target_link_libraries(test ${OpenCV_LIBS} ${LIBLAS_LIBRARIES} optimized ${LIBE57_LIBRARIE

我有一个为项目生成NSVC项目的cmake,它包括共享格式的opencv(使用*.dll)

我想更改cmake,以便它可以链接opencv静态库

我的cmake的简单形式如下:

find_package(OpenCV REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test
    ${OpenCV_LIBS}
    ${LIBLAS_LIBRARIES}
    optimized ${LIBE57_LIBRARIES}
    debug ${LIBE57_LIBRARIES_DEBUG}
    optimized ${CERES_LIBRARIES}
    debug ${CERES_LIBRARIES_DEBUG})
cmake -G "Visual Studio 11 Win64"  path/to/target/project
我称之为cmake,如下所示:

find_package(OpenCV REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test
    ${OpenCV_LIBS}
    ${LIBLAS_LIBRARIES}
    optimized ${LIBE57_LIBRARIES}
    debug ${LIBE57_LIBRARIES_DEBUG}
    optimized ${CERES_LIBRARIES}
    debug ${CERES_LIBRARIES_DEBUG})
cmake -G "Visual Studio 11 Win64"  path/to/target/project
根据我在这里发现的一些问题,我尝试了这些,但没有一个有效:

  • 我将此添加到cmake的开头:

    设置(生成共享库,FALSE)

  • 我给cmake打电话如下:

    find_package(OpenCV REQUIRED)
    add_executable(test test.cpp)
    target_link_libraries(test
        ${OpenCV_LIBS}
        ${LIBLAS_LIBRARIES}
        optimized ${LIBE57_LIBRARIES}
        debug ${LIBE57_LIBRARIES_DEBUG}
        optimized ${CERES_LIBRARIES}
        debug ${CERES_LIBRARIES_DEBUG})
    
    cmake -G "Visual Studio 11 Win64"  path/to/target/project
    
    cmake-G-DBUILD_SHARED_LIBS=OFF“Visual Studio 11 Win64”路径/目标/项目


  • 问题是什么?我如何解决它?

    -G“Visual Studio 11 Win64”//不要将它们分开谢谢。这很有效,但我如何在cmake中设置它?