MinGw编译opencv教程

编译不好弄,要在线下载库。

首先上个参考链接:https://blog.csdn.net/m0_60352504/article/details/122321538

](https://blog.csdn.net/m0_60352504/article/details/122321538)

第二个参考:https://blog.csdn.net/qq_43627907/article/details/124769922

编译时出现 Python 版本报错参考下面链接:
https://blog.csdn.net/weixin_44077524/article/details/123263192

MinGw编译opencv教程_第1张图片

这这里设置变量值。

MinGw链接到opencv

首先确定cmakelists.txt的配置内容:

cmake_minimum_required(VERSION 3.0)
project(ch7_StructureLightStereoTriangle)
set(CMAKE_CXX_STANDARD 11)
#重点
set(OpenCV_DIR D:\\Download\\OpenCV-MinGW-Build-OpenCV-4.5.5-x64\\OpenCV-MinGW-Build-OpenCV-4.5.5-x64)
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
message(STATUS "版本: ${OpenCV_VERSION}")
message(STATUS "库: ${OpenCV_LIBS}")
message(STATUS "路径: ${OpenCV_INCLUDE_DIRS}")
add_executable(main.cpp)
target_link_libraries(ch7_StructureLightStereoTriangle
        ${OpenCV_LIBS}
        )

重点:主要是要设置 OpenCV_DIR 变量的路径为 opencv的路径,要找 OpenCVConfig.cmake

编译命令: 1、 cmake.exe -G “MinGW Makefiles” …
2、 make

注意:MinGw编译时不能有中文路径,中文路径会找不到库。

你可能感兴趣的:(cmake,c++,cmake)