Tag Archives: bazel Compile Error

bazel Compile Error: absl/base/policy_checks.h:79:2: error: #error “C++ versions less than C++14 are not supported.”

An error is reported when compiling a software using bazel, and the error message is:

absl/base/policy_checks.h:79:2: error: #error “C++ versions less than C++14 are not supported.”

 

The entire compilation information is:

devil@hp:~/lab$ bazel build -c opt // :deepmind_lab.so 
INFO: Build option -- cxxopt has changed, discarding analysis cache. 
WARNING: Download from https: // mirror.bazel.build/github.com /glennrp/libpng/archive/v1.6.37.zip failed: class java.io.FileNotFoundException GET returned 404 Not Found 
DEBUG: Rule 
' com_google_absl ' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = " cd8a6aed3682cd6a0330e0c11828254877531109d7bddc9331109d7bddc9 Repository com_google_absl instantiated at: /home/devil/lab/WORKSPACE: 18 : 13
  : in <toplevel> 
Repository rule http_archive defined at:
   /home/devil/.cache/bazel/_bazel_devil/485f2e56923c3d722a11a1d362ce5e93/external/bazel_tools/tools/build_defs/repo/http.bzl: 355 : 31 : in <toplevel> 
DEBUG: Rule ' bazel_skylib ' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = " a9432ad1582da1dd8a2bcbbdaf11d887b38d97c226207b00471eeb2985576797 " DEBUG 
: Repository bazel_skylib instantiated at: 
  / home/devil/lab/ in : WORK : SPACE : 12
Repository rule http_archive defined at:
   /home/devil/.cache/bazel/_bazel_devil/485f2e56923c3d722a11a1d362ce5e93/external/bazel_tools/tools/build_defs/repo/http.bzl: 355 : 31 : in <toplevel> 
INFO: Analyzed target // :deepmind_lab .so (0 packages loaded, 4197 targets configured). 
INFO: Found 1 target... 
ERROR: /home/devil/.cache/bazel/_bazel_devil/485f2e56923c3d722a11a1d362ce5e93/external/com_google_absl/absl/types/BUILD.bazel: 153 : 11 : Compiling absl/types/bad_optional_access.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but- set -parameter -Wno-free-nonheap- object -fno-omit-frame-pointer -g0 -O2 ' -D_FORTIFY_SOURCE=1 ' -DNDEBUG -ffunction-sections ... (remaining 36 arguments skipped) 

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging 
In file included from external/com_google_absl/absl/ base /config.h: 86 ,
                  fromexternal/com_google_absl/absl/types/bad_optional_access.h: 26 ,
                  from external/com_google_absl/absl/types/bad_optional_access.cc: 15 : 
external /com_google_absl/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." 
      | ^~~~~ 
Target // :deepmind_lab.so failed to build 
Use -- verbose_failures to see the command lines of failed build steps. 
INFO: Elapsed time: 0.426s, Critical Path: 0 .26s 
INFO: 17 processes: 17  internal . 
FAILED: Build did NOT complete successfully

 

Solution:

Edit the file .bazelrc under home (this file generally does not exist in advance, you can save it directly after editing)

 

Fill in the content:

build –cxxopt=-std=c++14 

 

 

 

 

 

Execute the compilation again and successfully pass: