OpenCV 3.2 文件编译
OpenCV 3.2 file compilation?
如何在Windows 10中使用opencv 3.2,mingw和命令窗口编译c ++文件(包括opencv)。(我不想使用任何软件,如codeblocks/Vbasic/eclipse/netbeans)。
尝试使用 cmake 生成生成文件,然后将其用于生成和构建。
下面是一个 cmake 的最小示例,其中我使用 opencv 进行像素聚类。
您需要创建一个 CMakeLists.txt 文件并添加以下内容。 有关构建的更多信息,您可以查看我的GitHub存储库:https://github.com/anubhavrohatgi/ImageProcessing.git
#Cmake for Clustering Project
PROJECT(clustering)
#Minimum version of Cmake required
cmake_minimum_required(VERSION 3.1)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF(NOT CMAKE_BUILD_TYPE)
#Find and add opencv libraries
find_package(OpenCV REQUIRED core imgproc highgui imgcodecs)
IF(${OpenCV_VERSION} VERSION_LESS 2.4.12)
MESSAGE(FATAL_ERROR "OpenCV version is not compatible : ${OpenCV_VERSION}")
ENDIF()
#Check for C++ Compiler version. I am using C++14.
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
IF(COMPILER_SUPPORTS_CXX14)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
ELSEIF(COMPILER_SUPPORTS_CXX0X)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ELSE()
MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
ENDIF()
#include the header files located in the include folder
INCLUDE_DIRECTORIES(include)
#Set the variables for Headers and Sources. Manually add the filenames. This
#is useful if the files are changed, removed or name modified.
#Better than GLOB version
SET( HEADERS
include/clustering.h
)
set( SOURCES
src/main.cpp
)
add_executable(clustering ${SOURCES} ${HEADERS})
target_link_libraries(clustering
${OpenCV_LIBS}
)
相关文章:
- 使用 MEX 编译C++文件
- 获取 clang++:错误:在编译文件系统库的代码时
- 如何交叉编译C++文件
- 使用 MinGW 在 Windows 上的命令行编译C++文件
- 选择特定版本的 Visual Studio 命令行工具包,并根据特定版本的C++运行时环境编译文件
- 解析模板和范围后获取编译文件?
- 我的 PowerShell 脚本无法按预期工作(用于编译C++文件)
- 如何在不制作Visual Studio 2017项目的情况下编译C++文件?
- 'void *' 'void (*) (bool)' 指针使用 c ++ 编译器在 C 中编译文件的错误
- 在没有节点GYP的目标平台上编译C/C 文件
- 生成文件似乎以错误的顺序编译文件
- 编译 C++ 文件失败,因为找不到"ssize_t"的定义
- NeatBeans Makefile:麻烦编译.H文件
- 我无法编译文件系统库
- 在不使用预编译头C++项目中编译 C 文件
- 无法使用 Xcode 和终端在 Mac OS 上使用 OpenGL 库编译 c++ 文件
- 获取编译文件的列表,并由Make Project包含
- MinGW .h 编译文件不起作用:此文件的版本与您运行的 Windows 版本不兼容
- 编译 c++ 文件时出错:未定义的符号
- C++编译文件