0

I am trying to build and install Drake from source in order to get support for Mosek. I keep running into trouble, however. For the record, I am running macOS Catalina.

Right now my approach has been this:

  1. Clone drake from github to a location on my computer (from https://github.com/RobotLocomotion/drake.git)
  2. Install prereqs with ./setup/mac/install_prereqs.sh
  3. Run bazel build //... Make a directory called build and cd build cmake .. and then make and make install
  4. And in my C++ project, which I build using cmake, I add this to CMakeLists.txt: link_directories(drakelocation/build/install/lib) include_directories(drakelocation/build/install/include)

However, when I try to build my project, I get an error that Drake is unable to locate Eigen: 'Eigen/Core' file not found. I was able to work around this by adding:

target_link_libraries(my_lib Eigen3::Eigen) to my CMakeLists.txt

I found this a bit strange, as I expect that Drake includes Eigen when it is built, but at least this made me able to get a bit further.

After this I get a bunch of messages of the type: no member named 'signbit' in the global namespace

i.e. it seems like Drake suddenly is missing all the standard C++ libraries. I have not yet been able to fix this issue, so this is where I am currently stuck.

Do you have any suggestions, or have you encountered any similar problems before?

Other information:

  • Using find_package(drake) does not work with my current approach at all (cmake is not able to locate drake-config.cmake). Am I missing something here that is required to make this work? Where does cmake expect libraries to be installed, and how do I install them in that place?
  • I have also tried skipping the entire bazel build //... step, going directly to the cmake .. step, which did not seem to make any difference.
  • In between every different build approach I have run bazel clean --expunge to make sure that nothing sticks around from the previous run.

Thanks!

bernhardpg
  • 61
  • 5

2 Answers2

0

You need to tell CMake where your Drake installation is located:

list(APPEND CMAKE_PREFIX_PATH /absolute/path/to/drakelocation/build/install)
find_package(drake REQUIRED)

add_library(my_lib ...)
target_link_libraries(my_lib drake::drake)

This ensures you have all the necessary compiler and linker flags. Setting the include directory to simply /absolute/path/to/drakelocation/build/install/include is insufficient since it does not contain the include directories of the various dependencies of Drake.

Note that you do not need to call bazel yourself before calling cmake. When you run make install, it will call bazel internally.

0

Thanks @Jamie that solved the find_package() problem I had.

I still had some trouble with the build. Turns out that there was something wrong with my default SDK path, and that setting "CMAKE_OSX_SYSROOT" according to this: Catalina C++: Using <cmath> headers yield error: no member named 'signbit' in the global namespace after an update to XCode did the trick.

After this, I got a lot of strange error messages from Eigen, complaining that i.e. MatrixXd was not defined in the namespace 'Eigen'. For some reason, uninstalling it with brew uninstall eigen and then downloading and building eigen from source solved those problems.

It now works!

bernhardpg
  • 61
  • 5