opencv 编译报错: error: temporary of non-literal type 'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>' in a constant expression
完整报错:
C:\Users\MyName\MyProject\lib\include\google\protobuf\stubs\mutex.h:124: error: temporary of non-literal type 'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>' in a constant expression In file included from lib\include/google/protobuf/descriptor.h:66:0, from lib\include/google/protobuf/message.h:121, from lib\include/google/protobuf/generated_message_bases.h:42, from src/protodata/myfile.pb.h:26, from src/myfile/myfile.h:12, from src\myclass/myclass.h:8, from src\mywidget.cpp:2: lib\include/google/protobuf/stubs/mutex.h: In constructor 'constexpr google::protobuf::internal::WrappedMutex::WrappedMutex()': lib\include/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() {} ^ lib\include/google/protobuf/stubs/mutex.h:98:7: note: 'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>' is not literal because: class CallOnceInitializedMutex { ^~~~~~~~~~~~~~~~~~~~~~~~ lib\include/google/protobuf/stubs/mutex.h:98:7: note: 'google::protobuf::internal::CallOnceInitializedMutex<std::mutex>' has a non-trivial destructor
MinGW GCC: 5.3.0
OpenCV: 4.5.5
参考stackoverflow发现是GCC版本太低
在Opencv源代码中修改: opencv-4.5.5\3rdparty\protobuf\src\google\protobuf\stubs\mutex.h
重新编译
参考: https://stackoverflow.com/questions/69232278/c-protocol-buffer-temporary-of-non-literal-type-googleprotobufinternal