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
Comments
@dkurt Could you take a look? |
Please add CMake summary during the build step. Also, can you try add |
Stil fails and seems to require C++17
Specifying |
From the file // 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. Here is the reference to the absl::string_view file: 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.
Edit: Your absl build is builded with 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. |
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. |
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 |
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 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 |
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
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. https://github.com/abseil/abseil-cpp/releases/tag/20230125.2
|
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 Could you update flatbuffers in OpenCV 3rdparty? |
@asmorkalov, please check #23600. |
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:
Surprisingly the absl/strings/string_view.h include is part of stubs/common.h for very long time: |
Hello, creating other issue is better because the root causes is same, but it is a different issue. (flatbuffer and protobuf). After Protobuf v22, C++11 support has been dropped. https://github.com/protocolbuffers/protobuf/releases/tag/v22.0
The internal protobuf module in OpenCV/3rdpart is v19(3.19). It is supported C++11(it is opencv default setting). opencv/3rdparty/protobuf/README.md Lines 1 to 3 in 07bf9cb
I think ...
Lines 1172 to 1174 in 07bf9cb
|
FWIW: I've tried with |
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>
Hello, I make pull request to support protobuf v22 and later. If you have any question or suggestion, (This issue has been closed already, so it is not to better to continue other topics.) |
@Kumataro, can this issue be closed as PR has been merged? |
@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. |
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:
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
The text was updated successfully, but these errors were encountered: