Windows opencv cmake编译报错

opencv-c++版本:4.6.0

cmake版本:3.25

系统:win11

编译过程遇到的错误:

1.mingw32-make 后+j8和不加j8报错是不一样的

+j8编译会快很多,但报错要早。所以会先+j8把能通过的编译一下,卡住后删掉j8重新编译,这俩命令用谁都可,不需分得特别清晰。

2.卡到47%,libprotobuf生成失败

[ 46%] Building CXX object modules/photo/CMakeFiles/opencv_perf_photo.dir/perf/opencl/perf_denoising.cpp.obj
[ 46%] Building CXX object modules/photo/CMakeFiles/opencv_perf_photo.dir/perf/perf_cuda.cpp.obj
[ 46%] Building CXX object modules/photo/CMakeFiles/opencv_perf_photo.dir/perf/perf_inpaint.cpp.obj
[ 47%] Building CXX object modules/photo/CMakeFiles/opencv_perf_photo.dir/perf/perf_main.cpp.obj
[ 47%] Linking CXX executable ..\..\bin\opencv_perf_photo.exe
[ 47%] Built target opencv_perf_photo
[ 47%] Building CXX object 3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.obj
In file included from D:\Download\opencv\sources\3rdparty\protobuf\src\google\protobuf\arena.cc:42:0:
D:/Download/opencv/sources/3rdparty/protobuf/src/google/protobuf/stubs/mutex.h: In constructor 'constexpr google::protobuf::internal::WrappedMutex::WrappedMutex()':
D:/Download/opencv/sources/3rdparty/protobuf/src/google/protobuf/stubs/mutex.h:124:29: error: temporary of non-literal type 'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>' in a constant expression
   constexpr WrappedMutex() {}
                             ^
D:/Download/opencv/sources/3rdparty/protobuf/src/google/protobuf/stubs/mutex.h:98:7: note: 'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>' is not literal because:
 class CallOnceInitializedMutex {
       ^
D:/Download/opencv/sources/3rdparty/protobuf/src/google/protobuf/stubs/mutex.h:98:7: note:   'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>' has a non-trivial destructor
3rdparty\protobuf\CMakeFiles\libprotobuf.dir\build.make:90: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.obj' failed
mingw32-make[2]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/src/google/protobuf/arena.cc.obj] Error 1
CMakeFiles\Makefile2:1727: recipe for target '3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all' failed
mingw32-make[1]: *** [3rdparty/protobuf/CMakeFiles/libprotobuf.dir/all] Error 2
Makefile:164: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

 解决方法:

cmake取消勾选BUILD_PROTOBUF和WITH_PROTOBUF

3.opencv_calib3d生成失败

从这里开始,发现只要无法生成的库,就去cmake里取消掉,重新configure和generate,再mingw32-make即可。

我取消勾选这两个库之后,编译通过。


版权声明:本文为weixin_72599472原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
THE END
< <上一篇
下一篇>>