1

trying to pull and build Visqol following the instructions provided for Linux. I downloaded Bazel, everything seems fine. But when I try to execute with bazel build :visqol -c opt i get the following errors

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

I've seen similar issues in c++ on the web but most of these are building with make commands and solve this by adding the -lstdc++fs or LDLIBS=-lstdc++fs options. However, those are unrecognized for Bazel

I'm on Debian 10.13 and my Bazel version is 5.3.1, my c++ version seems to be 8.3.0

tbarbot
  • 225
  • 1
  • 4
  • 18
  • Does [how to use std::filesystem on gcc 8?](https://stackoverflow.com/a/53202056/7582247) answer your question? – Ted Lyngmo Oct 06 '22 at 13:36
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Jesper Juhl Oct 06 '22 at 13:37
  • 1
    In `.bazelrc`, change the line `build --linkopt=-ldl` into `build --linkopt=-lstdc++fs -ldl` – Ted Lyngmo Oct 06 '22 at 13:45
  • @TedLyngmo As said, the -lstdc++fs is not recognized with Bazel – tbarbot Oct 06 '22 at 13:47
  • Did you add `-lstdc++fs` like I proposed? What does bazel have to say about it? I would have guessed that bazel would only forward the option to the compiler/linker. – Ted Lyngmo Oct 06 '22 at 13:48
  • 1
    My bad,your solution was correct i just had a typo error. Thank you so much, you can post it as an answer, I'll accept it The correct line is: "build --linkopt=-lstdc++fs" – tbarbot Oct 06 '22 at 13:54

1 Answers1

1

In accordance with how to use std::filesystem on gcc 8?, change the line build --linkopt=-ldl in .bazelrc into:

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

You could also open a ticket in the Visgol repo and tell them about this problem and get a proper solution in the future releases of Visgol.

Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108