首页 > 解决方案 > 构建 python 绑定 - 规则链接失败

问题描述

当我尝试make -jhttps://drake.mit.edu/python_bindings.html#python-bindings-binary运行时,我收到此错误:

# make -j
[ 12%] Performing build step for 'drake_cxx_python'
INFO: Analyzed target //:install (1 packages loaded, 3 targets configured).
INFO: Found 1 target...
ERROR: /home/dxy/manipulation/drake/examples/kuka_iiwa_arm/BUILD.bazel:125:16: Linking of rule '//examples/kuka_iiwa_arm:kuka_plan_runner' failed (Exit 1): cc failed: error executing command /usr/bin/cc @bazel-out/k8-opt/bin/examples/kuka_iiwa_arm/kuka_plan_runner-2.params

Use --sandbox_debug to see verbose messages from the sandbox cc failed: error executing command /usr/bin/cc @bazel-out/k8-opt/bin/examples/kuka_iiwa_arm/kuka_plan_runner-2.params

Use --sandbox_debug to see verbose messages from the sandbox
bazel-out/k8-opt/bin/multibody/parsing/_objs/parser/parser.pic.o:parser.cc:function drake::multibody::(anonymous namespace)::DetermineFileType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/multibody/parsing/_objs/parser/parser.pic.o:parser.cc:function drake::multibody::(anonymous namespace)::DetermineFileType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::_M_find_extension() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/parser/parser.pic.o:parser.cc:function drake::multibody::(anonymous namespace)::DetermineFileType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function std::filesystem::__cxx11::path::operator=(std::filesystem::__cxx11::path&&) [clone .part.222]: error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function std::filesystem::__cxx11::path::path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::filesystem::__cxx11::path>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::filesystem::__cxx11::path::format): error: undefined reference to 'std::filesystem::__cxx11::path::_M_split_cmpts()'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function std::filesystem::__cxx11::path::operator/=(std::filesystem::__cxx11::path const&): error: undefined reference to 'std::filesystem::__cxx11::path::has_root_directory() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function std::filesystem::__cxx11::path::operator/=(std::filesystem::__cxx11::path const&): error: undefined reference to 'std::filesystem::__cxx11::path::has_filename() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::GetFullPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::current_path[abi:cxx11]()'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::GetFullPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::lexically_normal() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::GetFullPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::GetFullPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::ResolveUri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, drake::multibody::PackageMap const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::lexically_normal() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::ResolveUri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, drake::multibody::PackageMap const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::ResolveUri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, drake::multibody::PackageMap const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::has_root_directory() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/detail_misc/detail_path_utils.pic.o:detail_path_utils.cc:function drake::multibody::internal::ResolveUri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, drake::multibody::PackageMap const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::current_path[abi:cxx11]()'
bazel-out/k8-opt/bin/multibody/parsing/_objs/package_map/package_map.pic.o:package_map.cc:function drake::multibody::PackageMap::Add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::status(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/multibody/parsing/_objs/package_map/package_map.pic.o:package_map.cc:function drake::multibody::(anonymous namespace)::GetParentDirectory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::parent_path() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/package_map/package_map.pic.o:package_map.cc:function drake::multibody::PackageMap::PopulateUpstreamToDrakeHelper(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) [clone .localalias.363]: error: undefined reference to 'std::filesystem::__cxx11::path::has_root_directory() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/package_map/package_map.pic.o:package_map.cc:function drake::multibody::PackageMap::PopulateUpstreamToDrakeHelper(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) [clone .localalias.363]: error: undefined reference to 'std::filesystem::__cxx11::path::has_filename() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/package_map/package_map.pic.o:package_map.cc:function drake::multibody::PackageMap::PopulateUpstreamToDrake(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::_M_find_extension() const'
bazel-out/k8-opt/bin/multibody/parsing/_objs/package_map/package_map.pic.o:package_map.cc:function drake::multibody::PackageMap::PopulateUpstreamToDrake(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::__cxx11::path::parent_path() const'
bazel-out/k8-opt/bin/common/_objs/drake_path/drake_path.pic.o:drake_path.cc:function drake::MaybeGetDrakePath[abi:cxx11](): error: undefined reference to 'std::filesystem::__cxx11::path::parent_path() const'
bazel-out/k8-opt/bin/common/_objs/find_resource/find_loaded_library.pic.o:find_loaded_library.cc:function drake::LoadedLibraryPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&): error: undefined reference to 'std::filesystem::read_symlink(std::filesystem::__cxx11::path const&)'
bazel-out/k8-opt/bin/common/_objs/find_runfiles/find_runfiles.pic.o:find_runfiles.cc:function drake::(anonymous namespace)::Create(): error: undefined reference to 'std::filesystem::__cxx11::path::lexically_normal() const'
bazel-out/k8-opt/bin/common/_objs/find_runfiles/find_runfiles.pic.o:find_runfiles.cc:function drake::(anonymous namespace)::Create(): error: undefined reference to 'std::filesystem::read_symlink(std::filesystem::__cxx11::path const&)'
collect2: error: ld returned 1 exit status
Target //:install failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 801.493s, Critical Path: 69.97s
INFO: 1333 processes: 20 internal, 1306 linux-sandbox, 7 worker.
FAILED: Build did NOT complete successfully
CMakeFiles/drake_cxx_python.dir/build.make:110: recipe for target 'drake_cxx_python-prefix/src/drake_cxx_python-stamp/drake_cxx_python-build' failed
make[2]: *** [drake_cxx_python-prefix/src/drake_cxx_python-stamp/drake_cxx_python-build] Error 1
CMakeFiles/Makefile2:931: recipe for target 'CMakeFiles/drake_cxx_python.dir/all' failed
make[1]: *** [CMakeFiles/drake_cxx_python.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

任何有关如何调试的建议将不胜感激。这是系统信息 -

如果从源代码构建:构建系统(Bazel,CMake)Bazel 版本:

# which bazel; bazel version
/usr/local/bin/bazel
Bazelisk version: v1.4.0
Build label: 3.7.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Oct 20 13:29:16 2020 (1603200556)
Build timestamp: 1603200556
Build timestamp as int: 1603200556

Bazel C++ 编译器:

# bazel run @drake//common:print_host_settings
Starting local Bazel server and connecting to it...
WARNING: ignoring LD_PRELOAD in environment.
INFO: Analyzed target //common:print_host_settings (22 packages loaded, 91 targets configured).
INFO: Found 1 target...
Target //tools/cc_toolchain:print_host_settings up-to-date:
  bazel-bin/tools/cc_toolchain/print_host_settings
INFO: Elapsed time: 3.664s, Critical Path: 0.05s
INFO: 5 processes: 4 internal, 1 linux-sandbox.
INFO: Build completed successfully, 5 total actions
INFO: Running command line: bazel-bin/tools/cc_toolchain/print_host_settings tooINFO: Build completed successfully, 5 total actions
++ uname -s
+ [[ Linux == Darwin ]]
+ capture_cc_env=tools/cc_toolchain/capture_cc.env
+ source tools/cc_toolchain/capture_cc.env
++ BAZEL_CC=/usr/bin/gcc
++ BAZEL_CC_FLAGS=
+ [[ ! -z /usr/bin/gcc ]]
++ python3 -c 'import os; print(os.path.realpath("/usr/bin/gcc"))'
+ BAZEL_CC=/usr/bin/x86_64-linux-gnu-gcc-8
+ /usr/bin/x86_64-linux-gnu-gcc-8 --version
x86_64-linux-gnu-gcc-8 (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

CMake 版本:

# which cmake; cmake --version
/usr/bin/cmake
cmake version 3.10.2

CMake C++ 编译器

# cmake -LA ./ | grep 'CMAKE_.*_COMPILER'
-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Bazel: /usr/local/bin/bazel (found suitable version "3.7.0", minimum required is "2.0") 
-- Found PythonInterp: /usr/bin/python3 (found suitable exact version "3.6.9") 
-- Found Git: /usr/bin/git (found version "2.17.1") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dxy/manipulation/tmp/drake
-- Cache values
BUILD_TESTING:BOOL=ON
BZRCOMMAND:FILEPATH=BZRCOMMAND-NOTFOUND
Bazel_EXECUTABLE:FILEPATH=/usr/local/bin/bazel
CMAKE_AR:FILEPATH=/usr/bin/ar
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_COLOR_MAKEFILE:BOOL=ON
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-8
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-8
CMAKE_CXX_FLAGS:STRING=
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc
CMAKE_C_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-8
CMAKE_C_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-8
CMAKE_C_FLAGS:STRING=
CMAKE_C_FLAGS_DEBUG:STRING=-g
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_EXE_LINKER_FLAGS:STRING=
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
CMAKE_INSTALL_PREFIX:STRING=/home/dxy/manipulation/tmp/drake/install
CMAKE_LINKER:FILEPATH=/usr/bin/ld
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
CMAKE_MODULE_LINKER_FLAGS:STRING=
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_NM:FILEPATH=/usr/bin/nm
CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
CMAKE_SHARED_LINKER_FLAGS:STRING=
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
CMAKE_SKIP_RPATH:BOOL=NO
CMAKE_STATIC_LINKER_FLAGS:STRING=
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
CMAKE_STRIP:FILEPATH=/usr/bin/strip
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
COVERAGE_COMMAND:FILEPATH=/usr/bin/gcov
COVERAGE_EXTRA_FLAGS:STRING=-l
CPACK_SOURCE_RPM:BOOL=OFF
CPACK_SOURCE_TBZ2:BOOL=ON
CPACK_SOURCE_TGZ:BOOL=ON
CPACK_SOURCE_TXZ:BOOL=ON
CPACK_SOURCE_TZ:BOOL=ON
CPACK_SOURCE_ZIP:BOOL=OFF
CTEST_SUBMIT_RETRY_COUNT:STRING=3
CTEST_SUBMIT_RETRY_DELAY:STRING=5
CVSCOMMAND:FILEPATH=CVSCOMMAND-NOTFOUND
CVS_UPDATE_OPTIONS:STRING=-d -A -P
DART_TESTING_TIMEOUT:STRING=1500
GITCOMMAND:FILEPATH=/usr/bin/git
GIT_EXECUTABLE:FILEPATH=/usr/bin/git
HGCOMMAND:FILEPATH=HGCOMMAND-NOTFOUND
LSB_RELEASE_EXECUTABLE:FILEPATH=/usr/bin/lsb_release
MAKECOMMAND:STRING=/usr/bin/cmake --build . --config "${CTEST_CONFIGURATION_TYPE}"
MEMORYCHECK_COMMAND:FILEPATH=/usr/bin/valgrind
MEMORYCHECK_SUPPRESSIONS_FILE:FILEPATH=
P4COMMAND:FILEPATH=P4COMMAND-NOTFOUND
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3
SCPCOMMAND:FILEPATH=/usr/bin/scp
SITE:STRING=dxy-ubuntu
SLURM_SBATCH_COMMAND:FILEPATH=SLURM_SBATCH_COMMAND-NOTFOUND
SLURM_SRUN_COMMAND:FILEPATH=SLURM_SRUN_COMMAND-NOTFOUND
SVNCOMMAND:FILEPATH=SVNCOMMAND-NOTFOUND
WITH_GUROBI:BOOL=OFF
WITH_MOSEK:BOOL=OFF
WITH_ROBOTLOCOMOTION_SNOPT:BOOL=OFF
WITH_SNOPT:BOOL=OFF

Git 修订版53d57507e

标签: drake

解决方案


查看https://drake.mit.edu/developers.html#supported-configurations,GCC 7.5 是 Ubuntu 18.04 支持的版本。

在上面的错误报告中看到/usr/bin/gcc显示为“GCC 8.4.0”是不寻常的。在我的系统上,我有:

$ file /usr/bin/gcc
/usr/bin/gcc: symbolic link to gcc-7
$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

根据https://github.com/RobotLocomotion/drake/blob/e4209905da25dd54b5e45daf0dc19d3cdad31250/common/filesystem.h#L13,它看起来像 Drake 使用(<filesystem>如果可用),所以也许 GCC 8 提供了该标头,但不是以 Drake 能够提供的方式正确链接到。

您可以改用 GCC 7.5 吗?那应该可以正常工作。


推荐阅读