接下来参考
https://www.jianshu.com/p/c3fd1794f659参考编译opencv
编译opencv!!!
mingw-build为新建文件夹,用cmake来编译一下opencv。
一开始cmake总是出错,后面把mingw环境配置了一下,configure成功了。之后再generate,成功了,显示generate done!
然后在
D:\software_install\opencv\opencv\mingw-build
路径下打开终端,mingw32-make -j8,错误了!!!
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/sjlj/x86_64-8.1.0-release-posix-sjlj-rt_v6-rev0.7z/download
查问题说是mingw不支持多进程,重新下载了一个mingw,重复之前的操作,成功!!!
然后就是在clion上配置opencv了。
set(OpenCV_DIR D:/software_download/OpenCV-MinGW-Build-OpenCV-4.5.5-x64/x64/mingw/lib)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(opencv_demo ${OpenCV_LIBS})
注意:路径是D:/software_download/OpenCV-MinGW-Build-OpenCV-4.5.5-x64/x64/mingw/lib,是有lib的,网上看了好多教程,没有lib,然后我就一直报错,CMake Error at CMakeLists.txt:10 (find_package): By not providing "FindOpenCV
,加上了lib,编译成功。
#include
//int main() {
// std::cout << "Hello, World!" << std::endl;
// return 0;
//}
#include
#include
using namespace cv;
int main() {
std::cout << "Hello, World!" << std::endl;
Mat src = imread("E:/code/c/opencv_demo/1.png");
imshow("123",src);
waitKey();
return 0;
}
这样在win11的clion上就可以使用opencv了!!!
注:自己编译opencv总是出错,可以使用编译好的opencv,直接可用
https://github.com/huihut/OpenCV-MinGW-Build/tree/OpenCV-4.5.5-x64