簡體   English   中英

使用 Bazel 構建對“std::filesystem”的未定義引用

[英]undefined reference to 'std::filesystem' using Bazel build

嘗試按照為 Linux 提供的說明拉取和構建Visqol 。我下載了 Bazel,一切似乎都很好。 但是當我嘗試使用bazel build:visqol -c opt執行時,出現以下錯誤

bazel-out/k8-opt/bin/_objs/visqol/main.o:main.cc:function main: error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/_objs/visqol/main.o:main.cc:function main: error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::FileExists(Visqol::FilePath const&): error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::FileExists(Visqol::FilePath const&): error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::ReadFilesToCompare(Visqol::FilePath const&): error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::BuildFilePairPaths(Visqol::CommandLineArgs const&): error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::BuildFilePairPaths(Visqol::CommandLineArgs const&): error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::BuildFilePairPaths(Visqol::CommandLineArgs const&): error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::Parse(int, char**): error: undefined reference to 'std::filesystem::current_path[abi:cxx11]()'
bazel-out/k8-opt/bin/_objs/visqol_lib/commandline_parser.o:commandline_parser.cc:function Visqol::VisqolCommandLineParser::Parse(int, char**): error: undefined reference to 'std::filesystem::current_path[abi:cxx11]()'
collect2: error: ld returned 1 exit status

我在 web 上的 c++ 中看到了類似的問題,但其中大部分是使用 make 命令構建的,並通過添加-lstdc++fsLDLIBS=-lstdc++fs選項來解決這個問題。 但是,Bazel 無法識別這些

我在 Debian 10.13 上,我的 Bazel 版本是 5.3.1,我的 c++ 版本好像是 8.3.0

按照how to use std::filesystem on gcc 8? ,將 .bazelrc 中的 build .bazelrc build --linkopt=-ldl行更改為:

build --linkopt=-lstdc++fs -ldl

您還可以在Visgol 存儲庫中打開一張票,告訴他們這個問題,並在 Visgol 的未來版本中獲得適當的解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM