使用 Bazel 构建 Drake 时遇到问题

Trouble while building Drake with Bazel

我一直在尝试在 Ubuntu 20.04 上使用 Bazel 从源代码构建 Drake,但是当我 运行

时出现以下错误
bazel run //tutorials:mathematical_program

来自 Drake 根目录:

INFO: Analyzed target //tutorials:mathematical_program (0 packages loaded, 3 targets configured).
INFO: Found 1 target...
ERROR: /home/user_name/git/drake/bindings/pydrake/systems/BUILD.bazel:88:21: Compiling bindings/pydrake/systems/primitives_py.cc failed: (Exit 1): 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 273 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
gcc: fatal error: Killed signal terminated program cc1plus
compilation terminated.
Target //tutorials:mathematical_program failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 7411.763s, Critical Path: 3155.48s
INFO: 1232 processes: 53 internal, 1179 linux-sandbox.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

我相信您 运行 内存不足,大概是因为 bazel 并行运行许多作业。您可以尝试 bazel run -—jobs=1 //tutorials:mathematical_program 并确保它有效吗? (当然你可以试试jobs>1,如果你喜欢。