在 Ubuntu VM 上构建 Drake

Building Drake on Ubuntu VM

我一直在尝试在 运行ning Ubuntu 18.04.5 虚拟机上安装 Drake。不幸的是,二进制安装和源代码安装都不起作用。在源码安装的情况下,我运行bazel build //...(和install_prereqs)脚本后一直弹出如下错误:

username@ubuntu:~/code/drake$ bazel build //...
INFO: Analyzed 7909 targets (0 packages loaded, 0 targets configured).
INFO: Found 7909 targets...
ERROR: /home/username/code/drake/multibody/plant/BUILD.bazel:56:17: C++ compilation of rule '//multibody/plant:multibody_plant_core' failed (Exit 4): 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 309 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox 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 309 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
gcc: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
INFO: Elapsed time: 131.608s, Critical Path: 109.56s
INFO: 81 processes: 56 internal, 25 linux-sandbox.
FAILED: Build did NOT complete successfully

我认为通过安装 gcc 8 可能会解决问题,就像在 this thread. I followed this guide 中安装多个版本 og gcc,将其设置为 8,然后出现此错误这样做:

username@ubuntu:~/code/drake$ bazel build //...
INFO: Analyzed 7909 targets (0 packages loaded, 0 targets configured).
INFO: Found 7909 targets...
ERROR: /home/username/.cache/bazel/_bazel_/129b6ae6fdda880475e3f0ac2268ff1a/external/lcm/BUILD.bazel:133:10: undeclared inclusion(s) in rule '@lcm//:lcm-logplayer':
this rule is missing dependency declarations for the following files included by 'lcm/lcm-logger/lcm_logplayer.c':
  '/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h'
  '/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h'
  '/usr/lib/gcc/x86_64-linux-gnu/8/include/stdint.h'
INFO: Elapsed time: 2.600s, Critical Path: 0.73s
INFO: 18 processes: 12 internal, 5 linux-sandbox, 1 worker.
FAILED: Build did NOT complete successfully

如果此信息有帮助,我在我的主机上安装了 Mac 二进制文件,它们似乎 运行 正确。

如有任何帮助,我们将不胜感激!

这不是 GCC 8 问题(您应该撤消 GCC 8 安装更改)。

错误信息“gcc: internal compiler error: Killed (program cc1plus)”表明编译器崩溃了。这很可能是因为它 运行 内存 (RAM) 不足。

如果构建使用多个内核进行编译,那么使用较少的并发编译应该会有所帮助。也许试试 bazel build //... -j 1。如果有帮助,您可以通过 https://docs.bazel.build/versions/master/guide.html#bazelrc-the-bazel-configuration-file 将其放入点文件中,以便在该机器上构建时始终限制作业。

但是,如果一次只编译一个文件,而您仍有 运行 内存,那么您可能需要增加虚拟机的内存分配。