ubuntu22.04在编译一个工程文件时,报错:
../common/libs/3rdparty/opencv3/linux-x86-64/include/opencv2/core/types_c.h:461:35: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘struct CvMat’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
461 | CvMat(const CvMat& m) { memcpy(this, &m, sizeof(CvMat));}
../../common/libs/3rdparty/boost/mpl/assert.hpp:188:21: error: unnecessary parentheses in declaration of ‘assert_arg’ [-Werror=parentheses]
188 | failed ************ (Pred::************
| ^~~~~~~~~~~~~~~~~~~
189 | assert_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type )
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190 | );
| ~
问题原因:
源代码期望的编译环境是ubuntu18.04,默认gcc/g++版本是7,ubuntu22.04默认的版本是11,不兼容导致编译报错,需要对其降级;
解决办法:
将gcc/g++版本从11降级为7;
降级方法参考博客:
Ubuntu22.04多版本gcc g++切换_ubuntu设置默认gcc-优快云博客
[ubuntu][原创]ubuntu22.04更换gcc版本为gcc-7_gcc11退回gcc7_FL1623863129的博客-优快云博客