首页 > 其他分享 >bazel编译报错:absl/base/policy_checks.h:79:2: error: #error

bazel编译报错:absl/base/policy_checks.h:79:2: error: #error

时间:2022-10-08 13:32:28浏览次数:92  
标签:devil absl bazel google 报错 error policy com

 

 

使用bazel编译一个软件时报错,报错的信息为:

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

 

整个的编译信息为:

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 = "cd8a6aed3682cd6a0330e0c11828254877531109d7bddc9398f504b314ec9128"
DEBUG: 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/WORKSPACE:12: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>
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,
from external/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

 

 

 

Google一下,找到相关资料:​​https://issuehint.com/issue/deepmind/lab/241​

解决方案:

bazel编译报错:absl/base/policy_checks.h:79:2: error: #error_c++14

 

 

 

虽然Google出了相关的解决方法,但是这个东西到底讲的是怎么具体做还是有些不清楚,后来个人尝试了一下,有了具体的操作:

编辑home下文件.bazelrc  (该文件一般都是预先不存在的,编辑后直接保存即可)

bazel编译报错:absl/base/policy_checks.h:79:2: error: #error_杂谈_02

 

填写内容:

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

 

bazel编译报错:absl/base/policy_checks.h:79:2: error: #error_c++14_03

 

 

 

 

 

再次执行编译,顺利通过:

bazel编译报错:absl/base/policy_checks.h:79:2: error: #error_杂谈_04

 

 

 

 

 

 

===============================================

 

 


标签:devil,absl,bazel,google,报错,error,policy,com
From: https://blog.51cto.com/u_15642578/5737417

相关文章