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

BUG : C++ versions less than C++14 are not supported #12393

Closed
Chellapandi opened this issue Apr 3, 2023 · 8 comments
Closed

BUG : C++ versions less than C++14 are not supported #12393

Chellapandi opened this issue Apr 3, 2023 · 8 comments

Comments

@Chellapandi
Copy link

Chellapandi commented Apr 3, 2023

What version of protobuf and what language are you using?
Version:

  • Protobuf : 21.12
  • protoc : libprotoc 3.17.3
  • Bazel : 5.4.0
  • bazel depenedency:
http_archive(
    name = "com_google_protobuf",
    sha256 = "2118051b4fb3814d59d258533a4e35452934b1ddb41230261c9543384cbb4dfc",
    strip_prefix = "protobuf-3.22.2",
    urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.22.2.tar.gz"],
 )

Language: Golang

What operating system (Linux, Windows, ...) and version?
MacOS Monterey - 12.6.3

What runtime / compiler are you using (e.g., python version or gcc version)
python - Python 3.8.8

What did you do?
When I do bazel build //..., build should be succeeded.

What did you expect to see
Build Successful.

What did you see instead?

In file included from external/com_google_absl/absl/crc/internal/cpu_detect.cc:15:
In file included from external/com_google_absl/absl/crc/internal/cpu_detect.h:18:
In file included from external/com_google_absl/absl/base/config.h:86:
external/com_google_absl/absl/base/policy_checks.h:79:2: error: "C++ versions less than C++14 are not supported."
#error "C++ versions less than C++14 are not supported."

To resolve this issue, I have added the below snippet in WORKSPACE.

http_archive(
      name = "com_google_absl",
      sha256 = "f88c0030547281e8283ff183db61564ff08d3322a8c2e2de4c40e38c03c69aea",
      strip_prefix = "abseil-cpp-c27ab06897f330267bed99061ed3e523e2606bf1",
      urls = ["https://github.com/abseil/abseil-cpp/archive/c27ab06897f330267bed99061ed3e523e2606bf1.zip"],
)

But I got below error:
/external/com_google_protobuf/src/google/protobuf/compiler/BUILD.bazel:101:11: no such package '@com_google_absl//absl/log': BUILD file not found in directory 'absl/log' of external repository @com_google_absl. Add a BUILD file to a directory to mark it as a package. and referenced by '@com_google_protobuf//src/google/protobuf/compiler:protoc_lib_nowkt'

I tried the below workaround as well.
bazel build --action_env=BAZEL_CXXOPTS="-std=c++20" //...
But no luck.

Anything else we should know about your project / environment
I have to use grpc-gateway library which uses 3.22.2. So it throws below error if I downgrade the version to 3.21.7.

version_service.pb.gw.go:16:2: imported and not used: "github.com/golang/protobuf/ptypes/empty"
version_service.pb.gw.go:36:15: undefined: emptypb
version_service.pb.gw.go:53:15: undefined: emptypb
@Chellapandi Chellapandi added the untriaged auto added to all issues by default when created. label Apr 3, 2023
@sanchayanghosh
Copy link

Here, the absl library seems not to support anything lesser than c++14. Maybe, you need to open the issue there.

@mrcece
Copy link

mrcece commented Apr 12, 2023

cmake page
"By default, CMake will use whatever C++ version is the system default. Since protobuf requires C++14 or newer,"

@awbraunstein
Copy link

I was running into this issue and solved it by adding the following to my project's .bazelrc

build --cxxopt=-std=c++14
build --host_cxxopt=-std=c++14

@Chellapandi
Copy link
Author

cmake page "By default, CMake will use whatever C++ version is the system default. Since protobuf requires C++14 or newer,"

@mrcece Thanks for the response. Should I include -DCMAKE_CXX_STANDARD=14 in .bazelrc? I have included --repo_env=-DCMAKE_CXX_STANDARD=14, but still getting the below error:

external/com_google_protobuf/src/google/protobuf/BUILD.bazel:117:8: Executing genrule @com_google_protobuf//src/google/protobuf:gen_wkt_cc_sources failed: (Aborted): bash failed: error executing command /bin/bash -c ... (remaining 1 argument skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
dyld[88000]: missing symbol called
/bin/bash: line 1: 88000 Abort trap: 6           bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/protoc_nowkt --cpp_out=dllexport_decl=PROTOBUF_EXPORT:bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/wkt --proto_path=$(dirname $(dirname $(dirname external/com_google_protobuf/src/google/protobuf/any.proto))) external/com_google_protobuf/src/google/protobuf/any.proto external/com_google_protobuf/src/google/protobuf/api.proto external/com_google_protobuf/src/google/protobuf/duration.proto external/com_google_protobuf/src/google/protobuf/empty.proto external/com_google_protobuf/src/google/protobuf/field_mask.proto external/com_google_protobuf/src/google/protobuf/source_context.proto external/com_google_protobuf/src/google/protobuf/struct.proto external/com_google_protobuf/src/google/protobuf/timestamp.proto external/com_google_protobuf/src/google/protobuf/type.proto external/com_google_protobuf/src/google/protobuf/wrappers.proto

Am I using it in a right way? Correct me if I am wrong.

@Chellapandi
Copy link
Author

Chellapandi commented Apr 12, 2023

I was running into this issue and solved it by adding the following to my project's .bazelrc

build --cxxopt=-std=c++14
build --host_cxxopt=-std=c++14

@awbraunstein I tired both, but no luck :(
Getting below error after including both options.

external/com_google_protobuf/src/google/protobuf/BUILD.bazel:117:8: Executing genrule @com_google_protobuf//src/google/protobuf:gen_wkt_cc_sources failed: (Aborted): bash failed: error executing command /bin/bash -c ... (remaining 1 argument skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
dyld[88000]: missing symbol called
/bin/bash: line 1: 88000 Abort trap: 6           bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/protoc_nowkt --cpp_out=dllexport_decl=PROTOBUF_EXPORT:bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/wkt --proto_path=$(dirname $(dirname $(dirname external/com_google_protobuf/src/google/protobuf/any.proto))) external/com_google_protobuf/src/google/protobuf/any.proto external/com_google_protobuf/src/google/protobuf/api.proto external/com_google_protobuf/src/google/protobuf/duration.proto external/com_google_protobuf/src/google/protobuf/empty.proto external/com_google_protobuf/src/google/protobuf/field_mask.proto external/com_google_protobuf/src/google/protobuf/source_context.proto external/com_google_protobuf/src/google/protobuf/struct.proto external/com_google_protobuf/src/google/protobuf/timestamp.proto external/com_google_protobuf/src/google/protobuf/type.proto external/com_google_protobuf/src/google/protobuf/wrappers.proto

@Chellapandi
Copy link
Author

Here, the absl library seems not to support anything lesser than c++14. Maybe, you need to open the issue there.

Thank you. Let me try that.

@Chellapandi
Copy link
Author

Thanks @Mizux for the patch clue. That issue has been fixed. But still facing below error which I have mentioned in the ticket.

version_service.pb.gw.go:16:2: imported and not used: "github.com/golang/protobuf/ptypes/empty"
version_service.pb.gw.go:36:15: undefined: emptypb
version_service.pb.gw.go:53:15: undefined: emptypb

@deannagarcia
Copy link
Member

As stated above, protobuf announced that C++ versions less than C++ 14 will no longer be supported so this is working as intended.

It seems your new issues is with gRPC, I recommend you file a bug there. If you are still having an issue with the protobuf library, please open a new ticket with reproduction instructions just for that bug.

@googleberg googleberg removed the untriaged auto added to all issues by default when created. label Feb 17, 2024
alex-mccarthy-unity added a commit to Unity-Technologies/ml-agents that referenced this issue Mar 6, 2024
This fixes builds of ONNX on OS X while installing ml-agents.

OS X builds use Xcode by default, and the Xcode compiler defaults to using C++98 mode for C++ ( https://stackoverflow.com/a/21349148 ). This causes errors building protocol buffer libraries, which need to be compiled with support for C++14 or newer ( protocolbuffers/protobuf#12393 (comment) ).

[This ONNX commit](onnx/onnx@a979e75) changes its compilation to use C++14 mode: releases that include this commit (1.15.0 or newer) build with Xcode by default.

ONNX 1.15.0 uses a newer protocol buffer library, so allow newer versions here too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants