clion mingw-w64编译opencv4.11

Where is the source code:D:\opencv4.11\opencv\sources

Where to build the binaries:选择要编译到的地方

点configure

点Specify the generator for this project: MinGW Makefiles

c:选择gcc

C++:选择g++

点finish

好了之后

勾选 WITH_OPENGL

不勾选 WITH_IPP

扫描二维码关注公众号,回复: 9757036 查看本文章

不勾选 WITH_MSMF

不勾选 ENABLE_PRECOMPILED_HEADERS

点configure

点generate

cd进刚刚编译到的地方

# 这个-j 8代表线程数,如果你有40核,你也可以-j 40

mingw32-make -j 8

如果不报错

mingw32-make install

环境变量中添加  ${Opencv}\install\x64\mingw\bin (${Opencv}换成刚刚编译的地方)

CMake

cmake_minimum_required(VERSION 3.14)
project(C_plus_plus11)

set(CMAKE_CXX_STANDARD 11)

# Where to find CMake modules and OpenCV
set(OpenCV_DIR "D:\\opencv4.11\\opencv\\opencv-build-mingw-w64\\install")
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")


find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

add_executable(C_plus_plus11 main.cpp)

# add libs you need
set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs)

# linking
target_link_libraries(C_plus_plus11 ${OpenCV_LIBS})

测试代码 

#include<opencv2/opencv.hpp>
#include<string>
int main(){
    std::string mode;
#ifndef NDEBUG
    mode="DEBUG";
#else
    mode="RELEASE";
#endif
    cv::Mat src=cv::imread("E:\\pirctures\\picasso.jpg");
    imshow(mode,src);
    cv::waitKey();
    cv::destroyAllWindows();
    return 0;
}
发布了93 篇原创文章 · 获赞 83 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_39942341/article/details/102562441
今日推荐