使用Bazel构建PyCoral时因C++版本引发编译错误
在Arch Linux 6.3.1上使用Bazel 5.4.1构建PyCoral的C++版本编译错误
在Arch Linux 6.3.1系统上用Bazel 5.4.1构建PyCoral时出现编译错误,推测是编译器默认使用C14而非C17导致的。错误信息显示std::string_view仅在C17及以上版本可用,相关代码无法识别该类型。已尝试修改Makefile和.bazelrc中的C版本配置,但未生效。
错误日志
In file included from bazel-out/host/bin/external/flatbuffers/src/_virtual_includes/flatbuffers/flatbuffers/base.h:217, from external/flatbuffers/src/util.cpp:40: /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) { | ^~~~~~~~~~~ bazel-out/host/bin/external/flatbuffers/src/_virtual_includes/flatbuffers/flatbuffers/base.h:219:23: error: 'string_view' in namespace 'absl' does not name a type 219 | typedef absl::string_view string_view; | ^~~~~~~~~~~ Target //src:_pywrap_coral failed to build
已修改的配置
Makefile内容
COMMON_BAZEL_BUILD_FLAGS := --compilation_mode=$(COMPILATION_MODE) \ --copt=-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION \ --copt=-DCMAKE_CXX_STANDARD=17 \ --cpu=$(CPU)
.bazelrc内容
build:linux --cxxopt=-std=c++17
内容的提问来源于stack exchange,提问作者Fiatguy85
相关产品推荐
相关产品推荐

