-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Closed
Description
System Information
OpenCV version: 4.x (master)
Operating System: Arch Linux
Compiler & compiler version: GCC 12.2.1
Detailed description
On compiling the DNN module, build fails with the below error logs:
[ 88%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/tflite/tflite_importer.cpp.o
In file included from /usr/include/absl/base/config.h:86,
from /usr/include/absl/base/attributes.h:37,
from /usr/include/absl/strings/string_view.h:39,
from /home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/base.h:237,
from /home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/array.h:22,
from /home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffers.h:24,
from /home/shreesh/c++/opencv/modules/dnn/misc/tflite/schema_generated.h:7,
from /home/shreesh/c++/opencv/modules/dnn/src/tflite/tflite_importer.cpp:8:
/usr/include/absl/base/policy_checks.h:79:2: error: #error "C++ versions less than C++14 are not supported."
79 | #error "C++ versions less than C++14 are not supported."
| ^~~~~
/usr/include/absl/strings/string_view.h:52:26: error: ‘string_view’ in namespace ‘std’ does not name a type
52 | using string_view = std::string_view;
| ^~~~~~~~~~~
/usr/include/absl/strings/string_view.h:52:21: note: ‘std::string_view’ is only available from C++17 onwards
52 | using string_view = std::string_view;
| ^~~
/usr/include/absl/strings/string_view.h:686:8: error: ‘string_view’ does not name a type
686 | inline string_view ClippedSubstr(string_view s, size_t pos,
| ^~~~~~~~~~~
/usr/include/absl/strings/string_view.h:697:11: error: ‘string_view’ does not name a type
697 | constexpr string_view NullSafeStringView(const char* p) {
| ^~~~~~~~~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/base.h:239:23: error: ‘string_view’ in namespace ‘absl’ does not name a type
239 | typedef absl::string_view string_view;
| ^~~~~~~~~~~
In file included from /home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h:31,
from /home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffers.h:29:
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/string.h:31:16: error: ‘string_view’ in namespace ‘flatbuffers’ does not name a type
31 | flatbuffers::string_view string_view() const {
| ^~~~~~~~~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/string.h:57:28: error: ‘string_view’ in namespace ‘flatbuffers’ does not name a type
57 | static inline flatbuffers::string_view GetStringView(const String *str) {
| ^~~~~~~~~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h:496:44: error: ‘flatbuffers::string_view’ has not been declared
496 | Offset<String> CreateString(flatbuffers::string_view str) {
| ^~~~~~~~~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h:551:56: error: ‘string_view’ in namespace ‘flatbuffers’ does not name a type
551 | Offset<String> CreateSharedString(const flatbuffers::string_view str) {
| ^~~~~~~~~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h: In member function ‘flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilder::CreateString(int)’:
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h:497:29: error: request for member ‘data’ in ‘str’, which is of non-class type ‘int’
497 | return CreateString(str.data(), str.size());
| ^~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h:497:41: error: request for member ‘size’ in ‘str’, which is of non-class type ‘int’
497 | return CreateString(str.data(), str.size());
| ^~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h: In member function ‘flatbuffers::Offset<flatbuffers::String> flatbuffers::FlatBufferBuilder::CreateSharedString(int)’:
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h:552:35: error: request for member ‘data’ in ‘str’, which is of non-class type ‘const int’
552 | return CreateSharedString(str.data(), str.size());
| ^~~~
/home/shreesh/c++/opencv/3rdparty/flatbuffers/include/flatbuffers/flatbuffer_builder.h:552:47: error: request for member ‘size’ in ‘str’, which is of non-class type ‘const int’
552 | return CreateSharedString(str.data(), str.size());
| ^~~~
make[2]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/build.make:1715: modules/dnn/CMakeFiles/opencv_dnn.dir/src/tflite/tflite_importer.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 89%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/backend.cpp.o
[ 89%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window.cpp.o
[ 89%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/roiSelector.cpp.o
[ 89%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_gtk.cpp.o
make[1]: *** [CMakeFiles/Makefile2:1332: modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 90%] Linking CXX static library ../../lib/libopencv_highgui.a
[ 90%] Built target opencv_highgui
make: *** [Makefile:166: all] Error 2
It seems like the flatbuffers 3rd party library ends up including Abseil headers installed on the system which requires C++14 to be enabled, but OpenCV sets C++11 which is causing this build failure.
Steps to reproduce
Install abseil using sudo pacman -S abseil-cpp
and try to build latest OpenCV master DNN module.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)