Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error in OpenCV DNN module: #error "C++ versions less than C++14 are not supported." #23466

Closed
3 of 4 tasks
tantei3 opened this issue Apr 6, 2023 · 18 comments · Fixed by #23600
Closed
3 of 4 tasks

Comments

@tantei3
Copy link
Contributor

tantei3 commented Apr 6, 2023

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)
@asmorkalov
Copy link
Contributor

@dkurt Could you take a look?

@dkurt dkurt self-assigned this Apr 7, 2023
@dkurt
Copy link
Member

dkurt commented Apr 7, 2023

Please add CMake summary during the build step.

Also, can you try add -DCMAKE_CXX_STANDARD=14 option?

@tantei3
Copy link
Contributor Author

tantei3 commented Apr 7, 2023

Please add CMake summary during the build step.

$ cmake -DOPENCV_GENERATE_PKGCONFIG=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DBUILD_LIST=dnn -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
-- The CXX compiler identification is GNU 12.2.1
-- The C compiler identification is GNU 12.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: x86_64
-- Found PythonInterp: /usr/bin/python (found suitable version "3.10.10", minimum required is "2.7")
CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
  CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:

  PYTHON_EXECUTABLE=/usr/bin/python

  PYTHON_VERSION_STRING=3.10.10

  Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
  or environment variables

Call Stack (most recent call first):
  cmake/OpenCVDetectPython.cmake:271 (find_python)
  CMakeLists.txt:647 (include)


-- Could NOT find Python2 (missing: Python2_EXECUTABLE Interpreter)
    Reason given by package:
        Interpreter: Wrong major version for the interpreter "/sbin/python"

-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.10.10", minimum required is "3.2")
-- Found PythonLibs: /lib64/libpython3.10.so (found suitable exact version "3.10.10")
<string>:1: DeprecationWarning:

  `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
  of the deprecation of `distutils` itself. It will be removed for
  Python >= 3.12. For older Python versions it will remain present.
  It is recommended to use `setuptools < 60.0` for those Python versions.
  For more details, see:
    https://numpy.org/devdocs/reference/distutils_status_migration.html


-- Looking for ccache - not found
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Success
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Success
-- Performing Test HAVE_CXX_WRETURN_TYPE
-- Performing Test HAVE_CXX_WRETURN_TYPE - Success
-- Performing Test HAVE_C_WRETURN_TYPE
-- Performing Test HAVE_C_WRETURN_TYPE - Success
-- Performing Test HAVE_CXX_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WADDRESS
-- Performing Test HAVE_CXX_WADDRESS - Success
-- Performing Test HAVE_C_WADDRESS
-- Performing Test HAVE_C_WADDRESS - Success
-- Performing Test HAVE_CXX_WSEQUENCE_POINT
-- Performing Test HAVE_CXX_WSEQUENCE_POINT - Success
-- Performing Test HAVE_C_WSEQUENCE_POINT
-- Performing Test HAVE_C_WSEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WFORMAT_SECURITY
-- Performing Test HAVE_CXX_WFORMAT_SECURITY - Success
-- Performing Test HAVE_C_WFORMAT_SECURITY
-- Performing Test HAVE_C_WFORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Success
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Success
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Success
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Success
-- Performing Test HAVE_C_WPOINTER_ARITH
-- Performing Test HAVE_C_WPOINTER_ARITH - Success
-- Performing Test HAVE_CXX_WSHADOW
-- Performing Test HAVE_CXX_WSHADOW - Success
-- Performing Test HAVE_C_WSHADOW
-- Performing Test HAVE_C_WSHADOW - Success
-- Performing Test HAVE_CXX_WSIGN_PROMO
-- Performing Test HAVE_CXX_WSIGN_PROMO - Success
-- Performing Test HAVE_C_WSIGN_PROMO
-- Performing Test HAVE_C_WSIGN_PROMO - Failed
-- Performing Test HAVE_CXX_WUNINITIALIZED
-- Performing Test HAVE_CXX_WUNINITIALIZED - Success
-- Performing Test HAVE_C_WUNINITIALIZED
-- Performing Test HAVE_C_WUNINITIALIZED - Success
-- Performing Test HAVE_CXX_WSUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_WSUGGEST_OVERRIDE - Success
-- Performing Test HAVE_C_WSUGGEST_OVERRIDE
-- Performing Test HAVE_C_WSUGGEST_OVERRIDE - Failed
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_CXX_WNO_COMMENT
-- Performing Test HAVE_CXX_WNO_COMMENT - Success
-- Performing Test HAVE_C_WNO_COMMENT
-- Performing Test HAVE_C_WNO_COMMENT - Success
-- Performing Test HAVE_CXX_WIMPLICIT_FALLTHROUGH_3
-- Performing Test HAVE_CXX_WIMPLICIT_FALLTHROUGH_3 - Success
-- Performing Test HAVE_C_WIMPLICIT_FALLTHROUGH_3
-- Performing Test HAVE_C_WIMPLICIT_FALLTHROUGH_3 - Success
-- Performing Test HAVE_CXX_WNO_STRICT_OVERFLOW
-- Performing Test HAVE_CXX_WNO_STRICT_OVERFLOW - Success
-- Performing Test HAVE_C_WNO_STRICT_OVERFLOW
-- Performing Test HAVE_C_WNO_STRICT_OVERFLOW - Success
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Success
-- Performing Test HAVE_CXX_WNO_LONG_LONG
-- Performing Test HAVE_CXX_WNO_LONG_LONG - Success
-- Performing Test HAVE_C_WNO_LONG_LONG
-- Performing Test HAVE_C_WNO_LONG_LONG - Success
-- Performing Test HAVE_CXX_PTHREAD
-- Performing Test HAVE_CXX_PTHREAD - Success
-- Performing Test HAVE_C_PTHREAD
-- Performing Test HAVE_C_PTHREAD - Success
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER
-- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER
-- Performing Test HAVE_C_FOMIT_FRAME_POINTER - Success
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS
-- Performing Test HAVE_CXX_FFUNCTION_SECTIONS - Success
-- Performing Test HAVE_C_FFUNCTION_SECTIONS
-- Performing Test HAVE_C_FFUNCTION_SECTIONS - Success
-- Performing Test HAVE_CXX_FDATA_SECTIONS
-- Performing Test HAVE_CXX_FDATA_SECTIONS - Success
-- Performing Test HAVE_C_FDATA_SECTIONS
-- Performing Test HAVE_C_FDATA_SECTIONS - Success
-- Performing Test HAVE_CXX_MSSE (check file: cmake/checks/cpu_sse.cpp)
-- Performing Test HAVE_CXX_MSSE - Success
-- Performing Test HAVE_CXX_MSSE2 (check file: cmake/checks/cpu_sse2.cpp)
-- Performing Test HAVE_CXX_MSSE2 - Success
-- Performing Test HAVE_CXX_MSSE3 (check file: cmake/checks/cpu_sse3.cpp)
-- Performing Test HAVE_CXX_MSSE3 - Success
-- Performing Test HAVE_CXX_MSSSE3 (check file: cmake/checks/cpu_ssse3.cpp)
-- Performing Test HAVE_CXX_MSSSE3 - Success
-- Performing Test HAVE_CXX_MSSE4_1 (check file: cmake/checks/cpu_sse41.cpp)
-- Performing Test HAVE_CXX_MSSE4_1 - Success
-- Performing Test HAVE_CXX_MPOPCNT (check file: cmake/checks/cpu_popcnt.cpp)
-- Performing Test HAVE_CXX_MPOPCNT - Success
-- Performing Test HAVE_CXX_MSSE4_2 (check file: cmake/checks/cpu_sse42.cpp)
-- Performing Test HAVE_CXX_MSSE4_2 - Success
-- Performing Test HAVE_CXX_MF16C (check file: cmake/checks/cpu_fp16.cpp)
-- Performing Test HAVE_CXX_MF16C - Success
-- Performing Test HAVE_CXX_MFMA
-- Performing Test HAVE_CXX_MFMA - Success
-- Performing Test HAVE_CXX_MAVX (check file: cmake/checks/cpu_avx.cpp)
-- Performing Test HAVE_CXX_MAVX - Success
-- Performing Test HAVE_CXX_MAVX2 (check file: cmake/checks/cpu_avx2.cpp)
-- Performing Test HAVE_CXX_MAVX2 - Success
-- Performing Test HAVE_CXX_MAVX512F (check file: cmake/checks/cpu_avx512.cpp)
-- Performing Test HAVE_CXX_MAVX512F - Success
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD (check file: cmake/checks/cpu_avx512common.cpp)
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD - Success
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD_MAVX512VL_MAVX512BW_MAVX512DQ (check file: cmake/checks/cpu_avx512skx.cpp)
-- Performing Test HAVE_CXX_MAVX512F_MAVX512CD_MAVX512VL_MAVX512BW_MAVX512DQ - Success
-- Performing Test HAVE_CPU_BASELINE_FLAGS
-- Performing Test HAVE_CPU_BASELINE_FLAGS - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_1 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_SSE4_2 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_FP16 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX2
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX2 - Success
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX
-- Performing Test HAVE_CPU_DISPATCH_FLAGS_AVX512_SKX - Success
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_HIDDEN - Success
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN - Success
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN
-- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Failed
-- Performing Test HAVE_LINK_AS_NEEDED
-- Performing Test HAVE_LINK_AS_NEEDED - Success
-- Performing Test HAVE_LINK_NO_UNDEFINED
-- Performing Test HAVE_LINK_NO_UNDEFINED - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for memalign
-- Looking for memalign - found
-- Found ZLIB: /lib64/libz.so (found suitable version "1.2.13", minimum required is "1.2.3")
-- Found JPEG: /lib64/libjpeg.so (found version "80")
-- Found TIFF: /lib64/libtiff.so (found version "4.5.0")
-- Found WebP: /lib64/libwebp.so
-- Found system OpenJPEG: openjp2 (found version "")
-- Found ZLIB: /lib64/libz.so (found version "1.2.13")
-- Found PNG: /lib64/libpng.so (found version "1.6.39")
-- Looking for /usr/include/libpng/png.h
-- Looking for /usr/include/libpng/png.h - not found
-- IPPICV: Downloading ippicv_2020_lnx_intel64_20191018_general.tgz from https://raw.githubusercontent.com/opencv/opencv_3rdparty/a56b6ac6f030c312b2dce17430eef13aed9af274/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz
-- found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
-- at: /home/shreesh/c++/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
-- found Intel IPP Integration Wrappers sources: 2020.0.0
-- at: /home/shreesh/c++/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
-- Found OpenBLAS libraries: /lib/libopenblas.so
-- Found OpenBLAS include: /usr/include
-- LAPACK(OpenBLAS): LAPACK_LIBRARIES: /lib/libopenblas.so
CMake Warning at cmake/OpenCVFindLAPACK.cmake:29 (message):
  LAPACK(OpenBLAS): CBLAS/LAPACK headers are not found in '/usr/include'
Call Stack (most recent call first):
  cmake/OpenCVFindLAPACK.cmake:156 (ocv_lapack_check)
  CMakeLists.txt:755 (include)


-- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR Atlas_BLAS_LIBRARY)
-- Looking for sgemm_
-- Looking for sgemm_ - not found
-- Found Threads: TRUE
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Found BLAS: /lib64/libopenblas.so
-- Looking for cheev_
-- Looking for cheev_ - not found
-- Looking for cheev_
-- Looking for cheev_ - not found
-- Looking for cheev_
-- Looking for cheev_ - found
-- Found LAPACK: /lib64/liblapack.so;/lib64/libopenblas.so
-- Performing Test HAVE_CXX_WNO_DEPRECATED
-- Performing Test HAVE_CXX_WNO_DEPRECATED - Success
-- Performing Test HAVE_CXX_WNO_MISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WNO_MISSING_PROTOTYPES - Failed
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WNO_SHADOW
-- Performing Test HAVE_CXX_WNO_SHADOW - Success
-- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER
-- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER - Success
-- Performing Test HAVE_CXX_WNO_UNUSED_LOCAL_TYPEDEFS
-- Performing Test HAVE_CXX_WNO_UNUSED_LOCAL_TYPEDEFS - Success
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE
-- Performing Test HAVE_CXX_WNO_SIGN_COMPARE - Success
-- Performing Test HAVE_CXX_WNO_SIGN_PROMO
-- Performing Test HAVE_CXX_WNO_SIGN_PROMO - Success
-- Performing Test HAVE_CXX_WNO_UNDEF
-- Performing Test HAVE_CXX_WNO_UNDEF - Success
-- Performing Test HAVE_CXX_WNO_TAUTOLOGICAL_UNDEFINED_COMPARE
-- Performing Test HAVE_CXX_WNO_TAUTOLOGICAL_UNDEFINED_COMPARE - Failed
-- Performing Test HAVE_CXX_WNO_IGNORED_QUALIFIERS
-- Performing Test HAVE_CXX_WNO_IGNORED_QUALIFIERS - Success
-- Performing Test HAVE_CXX_WNO_EXTRA
-- Performing Test HAVE_CXX_WNO_EXTRA - Success
-- Performing Test HAVE_CXX_WNO_UNUSED_FUNCTION
-- Performing Test HAVE_CXX_WNO_UNUSED_FUNCTION - Success
-- Performing Test HAVE_CXX_WNO_UNUSED_CONST_VARIABLE
-- Performing Test HAVE_CXX_WNO_UNUSED_CONST_VARIABLE - Success
-- Performing Test HAVE_CXX_WNO_SHORTEN_64_TO_32
-- Performing Test HAVE_CXX_WNO_SHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_WNO_INVALID_OFFSETOF
-- Performing Test HAVE_CXX_WNO_INVALID_OFFSETOF - Success
-- Performing Test HAVE_CXX_WNO_ENUM_COMPARE_SWITCH
-- Performing Test HAVE_CXX_WNO_ENUM_COMPARE_SWITCH - Failed
-- Performing Test HAVE_CXX_WNO_SUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_WNO_SUGGEST_OVERRIDE - Success
-- Performing Test HAVE_CXX_WNO_INCONSISTENT_MISSING_OVERRIDE
-- Performing Test HAVE_CXX_WNO_INCONSISTENT_MISSING_OVERRIDE - Failed
-- Performing Test HAVE_CXX_WNO_IMPLICIT_FALLTHROUGH
-- Performing Test HAVE_CXX_WNO_IMPLICIT_FALLTHROUGH - Success
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS
-- Performing Test HAVE_CXX_WNO_ARRAY_BOUNDS - Success
-- Performing Test HAVE_CXX_WNO_CLASS_MEMACCESS
-- Performing Test HAVE_CXX_WNO_CLASS_MEMACCESS - Success
-- Found JNI: /usr/lib/jvm/default/include  found components: AWT JVM
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Performing Test HAVE_C_WNO_UNUSED_VARIABLE
-- Performing Test HAVE_C_WNO_UNUSED_VARIABLE - Success
-- Performing Test HAVE_C_WNO_SHADOW
-- Performing Test HAVE_C_WNO_SHADOW - Success
-- Looking for dlerror in dl
-- Looking for dlerror in dl - found
-- Performing Test HAVE_C_WNO_IMPLICIT_FALLTHROUGH
-- Performing Test HAVE_C_WNO_IMPLICIT_FALLTHROUGH - Success
-- Performing Test HAVE_C_WNO_UNDEF
-- Performing Test HAVE_C_WNO_UNDEF - Success
-- Performing Test HAVE_C_WNO_SIGN_COMPARE
-- Performing Test HAVE_C_WNO_SIGN_COMPARE - Success
-- Performing Test HAVE_C_WNO_STRICT_PROTOTYPES
-- Performing Test HAVE_C_WNO_STRICT_PROTOTYPES - Success
-- ADE: Downloading v0.1.2a.zip from https://github.com/opencv/ade/archive/v0.1.2a.zip
-- Checking for module 'gtk+-3.0'
--   Found gtk+-3.0, version 3.24.37
-- Checking for module 'gtk+-2.0'
--   Found gtk+-2.0, version 2.24.33
-- Checking for module 'gthread-2.0>=2.32'
--   Found gthread-2.0, version 2.76.1
-- Checking for modules 'libavcodec;libavformat;libavutil;libswscale'
--   Found libavcodec, version 60.3.100
--   Found libavformat, version 60.3.100
--   Found libavutil, version 58.2.100
--   Found libswscale, version 7.1.100
-- Checking for module 'libavresample'
--   Package 'libavresample', required by 'virtual:world', not found
-- Checking for module 'gstreamer-base-1.0'
--   Found gstreamer-base-1.0, version 1.22.1
-- Checking for module 'gstreamer-app-1.0'
--   Found gstreamer-app-1.0, version 1.22.1
-- Checking for module 'gstreamer-riff-1.0'
--   Found gstreamer-riff-1.0, version 1.22.1
-- Checking for module 'gstreamer-pbutils-1.0'
--   Found gstreamer-pbutils-1.0, version 1.22.1
-- Checking for module 'gstreamer-video-1.0'
--   Found gstreamer-video-1.0, version 1.22.1
-- Checking for module 'gstreamer-audio-1.0'
--   Found gstreamer-audio-1.0, version 1.22.1
-- Checking for module 'libdc1394-2'
--   Package 'libdc1394-2', required by 'virtual:world', not found
-- Using whitelist: opencv_dnn
-- Module opencv_calib3d disabled by whitelist
-- Module opencv_features2d disabled by whitelist
-- Module opencv_flann disabled by whitelist
-- Module opencv_gapi disabled by whitelist
-- Module opencv_highgui disabled by whitelist
-- Module opencv_imgcodecs disabled by whitelist
-- Module opencv_java_bindings_generator disabled by whitelist
-- Module opencv_js_bindings_generator disabled by whitelist
-- Module opencv_ml disabled by whitelist
-- Module opencv_objc_bindings_generator disabled by whitelist
-- Module opencv_objdetect disabled by whitelist
-- Module opencv_photo disabled by whitelist
-- Module opencv_python_bindings_generator disabled by whitelist
-- Module opencv_python_tests disabled by whitelist
-- Module opencv_python3 disabled by whitelist
-- Module opencv_stitching disabled by whitelist
-- Module opencv_ts disabled by whitelist
-- Module opencv_video disabled by whitelist
-- Module opencv_videoio disabled by whitelist
-- Allocator metrics storage type: 'long long'
-- Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/shreesh/c++/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/int8layers/layers_common.lasx.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.rvv.cpp
-- Excluding from source files list: <BUILD>/modules/dnn/layers/cpu_kernels/conv_depthwise.lasx.cpp
--
-- General configuration for OpenCV 4.7.0-dev =====================================
--   Version control:               4.7.0-160-gce01123db2
--
--   Platform:
--     Timestamp:                   2023-04-07T11:52:25Z
--     Host:                        Linux 6.2.9-arch1-1 x86_64
--     CMake:                       3.26.3
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Debug
--
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (13 files):         + SSSE3 SSE4_1
--       SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (0 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (7 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (29 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (4 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/c++  (ver 12.2.1)
--     C++ flags (Release):         -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
--     Linker flags (Debug):        -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a   -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          /lib64/libz.so va va-drm dl m pthread rt
--     3rdparty dependencies:       ittnotify libprotobuf ippiw ippicv
--
--   OpenCV modules:
--     To be built:                 core dnn imgproc
--     Disabled:                    world
--     Disabled by dependency:      calib3d features2d flann gapi highgui imgcodecs java_bindings_generator js_bindings_generator ml objc_bindings_generator objdetect photo python3 python_bindings_generator python_tests stitching ts video videoio
--     Unavailable:                 java python2
--     Applications:                apps
--     Documentation:               NO
--     Non-free algorithms:         NO
--
--   GUI:
--     GTK+:                        YES (ver 3.24.37)
--       GThread :                  YES (ver 2.76.1)
--       GtkGlExt:                  NO
--     VTK support:                 NO
--
--   Media I/O:
--     ZLib:                        /lib64/libz.so (ver 1.2.13)
--     JPEG:                        /lib64/libjpeg.so (ver 80)
--     WEBP:                        /lib64/libwebp.so (ver encoder: 0x020f)
--     PNG:                         /lib64/libpng.so (ver 1.6.39)
--     TIFF:                        /lib64/libtiff.so (ver 42 / 4.5.0)
--     JPEG 2000:                   OpenJPEG (ver 2.5.0)
--     OpenEXR:                     OpenEXR::OpenEXR (ver 3.1.7)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
--
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      YES
--       avcodec:                   YES (60.3.100)
--       avformat:                  YES (60.3.100)
--       avutil:                    YES (58.2.100)
--       swscale:                   YES (7.1.100)
--       avresample:                NO
--     GStreamer:                   YES (1.22.1)
--     v4l/v4l2:                    YES (linux/videodev2.h)
--
--   Parallel framework:            pthreads
--
--   Trace:                         YES (with Intel ITT)
--
--   Other third-party libraries:
--     Intel IPP:                   2020.0.0 Gold [2020.0.0]
--            at:                   /home/shreesh/c++/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2020.0.0)
--               at:                /home/shreesh/c++/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
--     VA:                          YES
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  NO
--     Protobuf:                    build (3.19.1)
--     Flatbuffers:                 builtin/3rdparty (23.1.21)
--
--   OpenCL:                        YES (INTELVA)
--     Include path:                /home/shreesh/c++/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.10.10)
--     Libraries:                   NO
--     numpy:                       /home/shreesh/.local/lib/python3.10/site-packages/numpy/core/include (ver 1.24.2)
--     install path:                -
--
--   Python (for build):            /usr/bin/python3
--
--   Java:
--     ant:                         NO
--     JNI:                         /usr/lib/jvm/default/include /usr/lib/jvm/default/include/linux /usr/lib/jvm/default/include
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done (23.9s)
-- Generating done (0.1s)
-- Build files have been written to: /home/shreesh/c++/opencv/build

Also, can you try add -DCMAKE_CXX_STANDARD=14 option?

Stil fails and seems to require C++17

[ 89%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/src/tflite/tflite_importer.cpp.o
In file included 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/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....
make[1]: *** [CMakeFiles/Makefile2:1294: modules/dnn/CMakeFiles/opencv_dnn.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Specifying -DCMAKE_CXX_STANDARD=17 does seem to compile successfully.

@ocpalo
Copy link
Collaborator

ocpalo commented Apr 7, 2023

From the file opencv/3rdparty/flatbuffers/include/flatbuffers/base.h

    // Check for absl::string_view
    #elif __has_include("absl/strings/string_view.h")
      #include "absl/strings/string_view.h"
      namespace flatbuffers {
        typedef absl::string_view string_view;
      }
      #define FLATBUFFERS_HAS_STRING_VIEW 1

When you compile with C++14, It checks if you have absl library installed. Absl is not part of the OpenCV. My two cents is you installed this library in your system with C++17 flag. So It detects the absl library and tries to use it. The problem is, absl uses std::string_view if it compiled and installed with C++17 flag. I think this is why your build requires C++17.

Here is the reference to the absl::string_view file:

https://github.com/abseil/abseil-cpp/blob/42a3c030c958e6e099162b746ada04792b3a1c67/absl/strings/string_view.h#L50

You may not remember that you specified C++17 flag while installed absl or your compilers default version might be C++17. According to abseil, it uses the C++17 when it is.

      # Abseil libraries require C++14 as the current minimum standard. When
      # compiled with C++17 (either because it is the compiler's default or
      # explicitly requested), then Abseil requires C++17.

Edit:

Your absl build is builded with ABSL_USES_STD_STRING_VIEW flag. So it uses std::string_view.

I tried to address that issue in the Google Flatbuffers repository. I think it is unlikely to be merged but, if it is we can update the flatbuffers and this can be solved. If you can compile absl with C++17, you can compile your other projects with C++17 too.

@tantei3
Copy link
Contributor Author

tantei3 commented Apr 8, 2023

Abseil has been installed by package manager as some other package's depencency and I've not explicitly compiled/installed it. OpenCV build should by default not fail if abseil-cpp is present in the system, CMake should either enable C++17 standard (if supported by compiler), or fall back and disable flatbuffers to gracefully handle this build failure.

@blazmonster
Copy link

blazmonster commented Apr 8, 2023

I can see you are using g++ version 12.x and c++ standard is 11. Plz try to install https://github.com/abseil/abseil-cpp/archive/refs/tags/20220623.1.tar.gz package for abseil. You can find more info on https://github.com/abseil/abseil-cpp/releases/tag/20220623.1 .

Your package manager might have installed a higher version of abseil by default. It would be good if you check which version of abseil has been installed. And plz check you compiler version once manually. You can try
g++ -dM -E -x c++ /dev/null | grep -F __cplusplus to check which standard of c++ it is.

@saurabhmj11
Copy link

The error message you are seeing suggests that the OpenCV DNN module is not compatible with C++ versions below C++14. This is indicated by the following error message:

arduino
Copy code
/usr/include/absl/base/policy_checks.h:79:2: error: #error "C++ versions less than C++14 are not supported."
It appears that the code is using the string_view type from the C++17 standard library, which is not available in older versions of C++. This is causing errors in the compilation process.

To fix this error, you should ensure that you are using a version of C++ that is compatible with the OpenCV DNN module. In this case, you need to use C++14 or higher.

To set the language standard for your project, you can add the following line to your CMakeLists.txt file:

scss
Copy code
set(CMAKE_CXX_STANDARD 14)
This will set the language standard to C++14 for your project, which should be compatible with the OpenCV DNN module.

@Kumataro
Copy link
Contributor

Kumataro commented Apr 21, 2023

Hello, maybe this problem has been fixed in flatbuffers project already. So that it seems that it is better to update to latest flatbuffer release, which is https://github.com/google/flatbuffers/releases/tag/v23.3.3

Only use absl headers if C++14 is available. by (at)rouault in google/flatbuffers#7824

I tried to this patch, and I've confirmed that it suppresses compilation errors related C++ Version (but I haven't tested about any DNN module. ).

diff --git a/3rdparty/flatbuffers/include/flatbuffers/base.h b/3rdparty/flatbuffers/include/flatbuffers/base.h
index 86688cc6e4..219b6d308a 100644
--- a/3rdparty/flatbuffers/include/flatbuffers/base.h
+++ b/3rdparty/flatbuffers/include/flatbuffers/base.h
@@ -233,7 +233,7 @@ namespace flatbuffers {
       }
       #define FLATBUFFERS_HAS_STRING_VIEW 1
     // Check for absl::string_view
-    #elif __has_include("absl/strings/string_view.h")
+    #elif __has_include("absl/strings/string_view.h") && (__cplusplus >= 201411)
       #include "absl/strings/string_view.h"
       namespace flatbuffers {
         typedef absl::string_view string_view;

The flatbuffers uses abseil-cpp library. However it has been finished to support with C++11 at 2023/01/25.
So I think it will be difficult to continue using current flatbuffer with OpenCV 4.x(C++11).

https://github.com/abseil/abseil-cpp/releases/tag/20230125.2

Abseil now requires at least C++14 and follows Google's Foundational C++ Support Policy. See this table for a list of currently supported versions compilers, platforms, and build tools.

@ocpalo
Copy link
Collaborator

ocpalo commented Apr 29, 2023

My pull request about this issue merged into flatbuffers repository. When they release, we can update the flatbuffers repository in the OpenCV and close this issue.

Currently, latest google/flatbuffers is 23.3.3. We need to wait for the next release.

@dkurt
Copy link
Member

dkurt commented May 10, 2023

A new release of flatbuffers has been published including changes from @ocpalo: v23.5.9

@asmorkalov asmorkalov added this to the 4.8.0 milestone May 10, 2023
@asmorkalov
Copy link
Contributor

@dkurt Could you update flatbuffers in OpenCV 3rdparty?

@dkurt
Copy link
Member

dkurt commented May 10, 2023

@asmorkalov, please check #23600.

@shr-project
Copy link

This seems to be failing again, but now it's not caused by flatbuffers pulling absl/strings/string_view.h but protobuf itself as in:

In file included from TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/recipe-sysroot/usr/include/absl/base/config.h:86,
                 from TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/recipe-sysroot/usr/include/absl/base/attributes.h:37,
                 from TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/recipe-sysroot/usr/include/absl/strings/string_view.h:39,
                 from TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/recipe-sysroot/usr/include/google/protobuf/stubs/common.h:44,
                 from TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/recipe-sysroot/usr/include/google/protobuf/io/coded_stream.h:130,
                 from TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/build/modules/dnn/tensor.pb.h:24,
                 from TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/build/modules/dnn/tensor.pb.cc:4:
TOPDIR/tmp-glibc/work/core2-64-oe-linux/opencv/4.8.0/recipe-sysroot/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."
      |  ^~~~~

Surprisingly the absl/strings/string_view.h include is part of stubs/common.h for very long time:
protocolbuffers/protobuf@a3c8e2d
but I'm seeing this failure only after upgrading from protobuf 3.21.12 to 4.22.2

@Kumataro
Copy link
Contributor

Kumataro commented Oct 5, 2023

Hello, creating other issue is better because the root causes is same, but it is a different issue. (flatbuffer and protobuf).
We may need to consider compatibility with Google's C++ compiler support strategy for OpenCV4 and 5.

After Protobuf v22, C++11 support has been dropped.

https://github.com/protocolbuffers/protobuf/releases/tag/v22.0

[Cpp] Add C++20 reserved keywords
[Cpp] Dropped C++11 Support

The internal protobuf module in OpenCV/3rdpart is v19(3.19). It is supported C++11(it is opencv default setting).

Project: Protocol Buffers - Google's data interchange format
Source code: https://github.com/protocolbuffers/protobuf
Version: 3.19.1

I think ...

  1. using internal protobuf (v19) with C++11.
  2. using external protobuf(3.21.12=v21) with C++11
  3. using external probobuf(4.22.2 = v22) with C++17 (Maybe cmake optiuon -DCMAKE_CXX_STANDARD=17 is needed.)

opencv/CMakeLists.txt

Lines 1172 to 1174 in 07bf9cb

if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD)
status(" C++ standard:" "${CMAKE_CXX_STANDARD}")
endif()

@shr-project
Copy link

using external probobuf(4.22.2 = v22) with C++17 (Maybe cmake optiuon -DCMAKE_CXX_STANDARD=17 is needed.)

FWIW: I've tried with -DCMAKE_CXX_STANDARD=14 but that's not enough, because than it fails linking with various absl libs (might be separate issue as I was testing this only in cross compilation environment with OpenEmbedded - https://lists.openembedded.org/g/openembedded-devel/message/105355)

madisongh added a commit to OE4T/meta-tegra that referenced this issue Oct 6, 2023
OpenCV requires C++11 standard.  The dnn module adds
protobuf as a dependency, and the version currently
in meta-oe needs C++14.

See opencv/opencv#23466
and opencv/opencv#23791
for more information.

Disabling dnn for now.

Signed-off-by: Matt Madison <matt@madison.systems>
@Kumataro
Copy link
Contributor

Kumataro commented Oct 9, 2023

Hello, I make pull request to support protobuf v22 and later.

If you have any question or suggestion,
please could you use pullrequest or issue ?

(This issue has been closed already, so it is not to better to continue other topics.)

@asmorkalov asmorkalov reopened this Oct 12, 2023
@dkurt
Copy link
Member

dkurt commented Nov 13, 2023

@Kumataro, can this issue be closed as PR has been merged?

@Kumataro
Copy link
Contributor

@dkurt Yes, I think it is OK. Thank you !

Issue about supporting external protobuf v22 and later ( #23466 (comment) ) has been created and closed at #24369.

@dkurt dkurt closed this as completed Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants