1

I have been attempting to build Drake from source with Bazel on Ubuntu 18.04 but the following error occurs when I run

bazel build ...

from the Drake root directory:

ERROR: /home/username/dir/drake/bindings/pydrake/BUILD.bazel:56:37: Action bindings/pydrake/documentation_pybind.h failed (Exit 1) mkdoc failed: error executing command bazel-out/host/bin/tools/workspace/pybind11/mkdoc -DDRAKE_COMMON_SYMBOLIC_DETAIL_HEADER -DEIGEN_MPL2_ONLY -DHAVE_CSTDDEF '-DFMT_HEADER_ONLY=1' '-DFMT_NO_FMT_STRING_ALIAS=1' -DHAVE_SPDLOG ... (remaining 1096 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
external/eigen/include/_usr_include_eigen3/Eigen/Core:66:12: fatal error: 'new' file not found
Traceback (most recent call last):
  File "/home/username/.cache/bazel/_bazel_username/6e98757561df7a931d098ab985a3e673/sandbox/linux-sandbox/1371/execroot/drake/bazel-out/host/bin/tools/workspace/pybind11/mkdoc.runfiles/drake/tools/workspace/pybind11/mkdoc.py", line 841, in <module>
    main()
  File "/home/username/.cache/bazel/_bazel_username/6e98757561df7a931d098ab985a3e673/sandbox/linux-sandbox/1371/execroot/drake/bazel-out/host/bin/tools/workspace/pybind11/mkdoc.runfiles/drake/tools/workspace/pybind11/mkdoc.py", line 805, in main
    severities.count(cindex.Diagnostic.Fatal)))
RuntimeError: Parsing headers using the clang library failed with 0 error(s) and 1 fatal error(s)
----------------
Note: The failure of target //tools/workspace/pybind11:mkdoc (with exit code 1) may have been caused by the fact that it is running under Python 3 instead of Python 2. Examine the error to determine if that appears to be the problem. Since this target is built in the host configuration, the only way to change its version is to set --host_force_python=PY2, which affects the entire build.

If this error started occurring in Bazel 0.27 and later, it may be because the Python toolchain now enforces that targets analyzed as PY2 and PY3 run under a Python 2 and Python 3 interpreter, respectively. See https://github.com/bazelbuild/bazel/issues/7899 for more information.
----------------
INFO: Elapsed time: 2345.311s, Critical Path: 321.76s
INFO: 1378 processes: 1378 linux-sandbox.
FAILED: Build did NOT complete successfully

Prior to building, I ran:

sudo ./setup/ubuntu/install_prereqs.sh

as mentioned in the installation instructions.

I had also set the environment variables for the c and c++ compilers to $CC=/usr/bin/gcc and $CXX=/usr/bin/gcc because I was suspicious of compiler issues being the problem. To compare against this, I also tried to build with $CC=/usr/bin/clang-9 and $CXX=/usr/bin/clang++-9, with a different resulting error:

ERROR: /home/username/dir/drake/systems/framework/BUILD.bazel:213:17: C++ compilation of rule '//systems/framework:cache_and_dependency_tracker' failed (Exit 1) clang-9 failed: error executing command /usr/bin/clang-9 -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 77 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
In file included from systems/framework/cache.cc:1:
bazel-out/k8-opt/bin/systems/framework/_virtual_includes/cache_and_dependency_tracker/drake/systems/framework/cache.h:7:10: fatal error: 'cstdint' file not found
#include <cstdint>
         ^~~~~~~~~

I suspect that there is some issue with the include paths that are being used during build since both compilers were unable to find standard files, however I am unsure of what to try next or how to fix this. Any suggestions or advice would be greatly appreciated!

David
  • 11
  • 1
  • Can you confirm that you can run `install_prereqs.sh` with no errors indicated? It seems like something with your STL installation may be messed up? Another thing to try is completely isolating your environment. Can you try to adapt this script to your purposes? https://gist.github.com/EricCousineau-TRI/dd5bc43eeb05d1fb50277f236872d98b - you'll need to update the steps there (e.g. use Bazel instead of CMake, etc.) – Eric Cousineau Sep 26 '20 at 19:03
  • 1
    install_prereqs seems to run correctly with the only error being that it can't fetch bazel: https://storage.googleapis.com/bazel-apt/dists/stable/InRelease (not sure why, using bazel 3.5.0). Other than that there does not seem to be any errors and prints install_prereqs:success when finished. I tried to use your script to run the build in an isolated environment replacing the cmake code with bazel build ... from the drake root and it failed with a similar error to the first in the original post, only this time it was unable to find iostream instead of new. – David Sep 30 '20 at 01:28
  • 1
    I ended up installing g++-8 and completely rebuilding and that seemed to fix whatever the issue was. Thank you for the help! – David Oct 01 '20 at 00:50
  • Huh, odd... I wonder why `g++-8` solved the issue, as a viable version of `gcc` should've been installed via `install_prereqs`. Perhaps you had something overriding `CC / CXX`, or your `update-alternatives` had something odd in it? – Eric Cousineau Oct 01 '20 at 13:51

1 Answers1

0

This seems to be the same problem that I encountered. My Question is here Encounter "RuntimeError: The operating system's C++ standard library is not installed correctly" when build drake from source using bazel and I solve my problem following @jwnimmer-tri's answer.

It turns out that Clang is looking for GCC's standard library and it seems that it looks for GCC with higher version (not sure). I guess the problem is that you have gcc-8 installed but not g++-8, so after you install g++-8 you can fix the issue. Another possible way to solve your problem is to follow @jwnimmer-tri's answer in my question to remove gcc-8 completely.

Chen Wang
  • 448
  • 2
  • 11