一、各个组件
opencv
博主的版本:3.4.4
MinGw
Cmake
二、问题汇集
1. error: 'nullptr' was not declared in this scope
\opencv\sources\3rdparty\protobuf\src\google\protobuf\stubs\io_win32.cc:94:15: error: 'nullptr' was not declared in this scope
return s == nullptr || *s == 0;
解决方案:
在 cmake-gui 编译配置中:
勾选 ENABLE_CXX11
然后重新Configure -
> Generate -
> mingw32-make
2.error C2065: “MF_MT_AAC_PAYLOAD_TYPE”
opencv build with tbb error …\modules\videoio\src\cap_msmf.cpp(257): error C2065: “MF_MT_AAC_PAYLOAD_TYPE”
解决方案:
配置cmake时需要去掉WITH_MSMF和WITH_MSMFDXVA两个选项
3.error: ‘strcpy_s’ undeclared…
window_w32.cpp: In function 'void icvLoadWindowPos(const char*, CvRect&)'
48: error: 'strcpy_s' was not declared in this scope
error: 'strcat_s'was not declared in this scope
原因 :
原因是mingw下没有strcpy_s
函数,这是MSC的方法,mingw中不存在
解决方案:
所以window_w32.cpp文件中的strcpy_s和strcat_s都替换为strncpy和strncat。注意:替换后的函数参数顺序不同,也要调整
如下:
char szKey[1024];
strncpy( szKey, icvWindowPosRootKey, 1024 );
strncat( szKey, name , 1024);
4.clion win10 msvc opencv报错Process finished with exit code -1073741515 (0xC0000135)
参考:https://blog.csdn.net/weixin_40448140/article/details/104720134
需要在Clion启动时配置库文件路劲