简体   繁体   中英

Why do I get `fatal error: Eigen/Dense` when compiling Drake, even though `install_prereqs` succeeded?

On Ubuntu, when compiling Drake as an external , I get errors like the following:

$ bazel build @drake//proximity:proximity_utilities
...
ERROR: {bazel_cache}/external/drake/geometry/proximity/BUILD.bazel:557:17: Compiling geometry/proximity/proximity_utilities.cc failed: (Exit 1): gcc-7 failed: error executing command
...
Use --sandbox_debug to see verbose messages from the sandbox
In file included from external/fcl/include/fcl/math/bv/AABB.h:41:0,
...
                 from external/drake/geometry/proximity/proximity_utilities.cc:1:
external/fcl/include/fcl/common/types.h:46:10: fatal error: Eigen/Dense: No such file or directory
 #include <Eigen/Dense>
          ^~~~~~~~~~~~~

However, I ran install_prereqs per Drake's instructions.

What is the issue?

Most likely, you have a non-system version of Eigen that was installed via something like sudo make install , and its pkg-config file (eg /usr/local/share/pkgconfig/eigen.pc ) is shadowing the distribution's file ( /usr/share/pkgconfig/eigen3.pc ).

You can check this by running pkg-config --debug eigen3 , and checking for a line Saying Reading 'eigen3' from file '...' .

The simplest solution is to remove the offending pkg-config file(s), clean your bazel build, and rebuild. For example:

# WARNING: This may break / confuse other projects. If you can,
# see if you can uninstall using a more specific command.
# For example, if using CMake, try to install from the
# generated `install_manifest.txt`.
sudo rm /usr/local/share/pkgconfig/eigen3.pc

# Ensure the bazel build is fully cleaned to pick up newer
# file.
$ bazel clean --expunge --async

# Then rebuild.

# One simple target to rebuild and ensure it doesn't fail:
$ bazel build @drake//common:common

While it is sometimes useful to install to /usr/local out of convenience / prototyping, it can be bad because it can shadow / confuse other tools that may look for another version of packages on your system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM