ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
8

Building ROS on OSX 10.9 (solution)

asked 2013-10-27 06:06:49 -0500

Artem gravatar image

updated 2013-12-13 20:18:04 -0500

Building octomap, orocos_kdl and other packages on OSX 10.9 produces the following compilation errors

    /Users/artemlenskiy/ros/hydro/src/octomap/src/Pointcloud.cpp:37:12: fatal error: 'ext/algorithm' file not found
      #include <ext/algorithm>
               ^
    [ 29%] Building CXX object src/CMakeFiles/octomap.dir/AbstractOcTree.cpp.o
    In file included from /Users/artemlenskiy/ros/hydro/src/octomap/src/OcTreeLUT.cpp:37:
    In file included from /Users/artemlenskiy/ros/hydro/src/octomap/include/octomap/OcTreeLUT.h:40:
    /Users/artemlenskiy/ros/hydro/src/octomap/include/octomap/OcTreeKey.h:40:12: fatal error: 'tr1/unordered_set' file not found
      #include <tr1/unordered_set>
...

In the case of orocos_kdl

In file included from /Users/artemlenskiy/ros/hydro/src/orocos_kdl/src/kinfam_io.cpp:22:
In file included from /Users/artemlenskiy/ros/hydro/src/orocos_kdl/src/kinfam_io.hpp:25:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/string:434:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/algorithm:593:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/utility:221:9: error: field has incomplete type 'KDL::TreeElement'
    _T2 second;
edit retag flag offensive close merge delete

Comments

Did you find an answer to the orocos_kdl problem? I've built latest version of octomap/devel branch without problem, but I don't know yet how to solve this orocos_kdl error

Bruno Normande gravatar image Bruno Normande  ( 2013-11-18 09:16:45 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
10

answered 2013-11-14 00:51:05 -0500

jensenb gravatar image

updated 2014-08-05 14:19:58 -0500

Edit 5: These workarounds are no longer required. They are kept here purely for reference.

Some of the workarounds listed in this answer are no longer required as the changes have been merged into hydro. Below are the current workarounds still required to get ROS hydro working on Mavericks, suitable to both git and tar based rosinstall distributions.

OROCOS KDL Fix

There is a problem with OROCOS KDL API that is incompatible with libc++ and clang, discussed in more detail in PR 4 and PR 19. You will need to patch KDL source using both of these pull requests.

cd <ROS WORKSPACE DIR>/src/orocos_kinematics_dynamics
curl https://github.com/orocos/orocos_kinematics_dynamics/pull/4.patch | patch -p1
curl https://github.com/orocos/orocos_kinematics_dynamics/pull/19.patch | patch -p1
# it is not a problem if the following step fails
cd .. && rm -r build_isolated/orocos_kdl

You will also need to patch several dependent ROS packages. For the necessary robot model changes:

cd <ROS WORKSPACE DIR>/src/robot_model
curl https://github.com/ros/robot_model/pull/43.patch | patch -p1
# it is not a problem if the following step fails
cd .. && rm -r build_isolated/kdl_parser

for the necessary robot_state_publisher changes:

cd <ROS WORKSPACE DIR>/src/robot_state_publisher
curl https://github.com/ros/robot_state_publisher/pull/5.patch | patch -p1
# it is not a problem if the following step fails
cd ../.. && rm -r build_isolated /robot_state_publisher

OpenCV and Cuda

Currently OpenCV has issues when building with Cuda enabled, so you will have to disable it:

cd build_isolated/opencv/install
ccmake
# turn off the 'WITH_CUDA' flag and generate

Outdated workarounds no longer necessary

These workarounds are no longer necessary but I am keeping them here for historical reasons in case someone has an older workspace and doesn't want to update.

Prerequisite for any of the following steps is understanding how to checkout Github pull requests locally. The rest of these fixes are currently involve API breaking changes and are under review. I make no guarantees about their correctness, only that they should at least build on Mavericks. For all of the commands below I always your current working directory is your ROS workspace root (NOT src subdirectory).

Octomap Fix

For this particular octomap problem there is a fix committed upstream that should allow compilation with libc++ with Mavericks: https://github.com/OctoMap/octomap/pu... . Due to the way ROS packages things, mergeing this change in to the ROS octomap source in your hydro workspace involves a bit of hand work on the command line:

cd <path to your hydro workspace>/src/octomap
git remote upstream git@github.com:OctoMap/octomap.git
git fetch upstream
git checkout release/hydro/octomap/1.6.1-0
git cherry-pick b7aec9182e102da32f0f210197a55b827e0ae894
git cherry-pick 8a9722d0f479dcde680dc689e0d071e48bb32e99

Rebuild your catkin workspace and the octomap errors should go away.

ROSCPP Message Traits

There is a problem with the roscpp message forward declarations that is discussed in more detail here. The workaround:

cd src/roscpp_traits
curl -o include/ros/message_forward.h https://raw.github.com/ros/roscpp_core/e4dff32c8847f7e9e16b3aecebbbbaf7d84daf5a/roscpp_traits/include ...
(more)
edit flag offensive delete link more

Comments

I had also troubles compiling rqt_image_view and rviz, although Hans did not have this problem. I had to add opencv_libs into CMakeLists.txt. BTW, I deleted opencv from src, because I prefer to have it installed through homebrew.

Artem gravatar image Artem  ( 2013-11-21 03:48:54 -0500 )edit

how did you add opencv_libs into rqt_image_view CMakeLists.txt ?

iRunner gravatar image iRunner  ( 2013-12-02 19:15:02 -0500 )edit

After adding opencv_libs to CMakeLists.txt the modified line looks like this target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${OPENCV_LIBRARY} ${OpenCV_LIBS})

Artem gravatar image Artem  ( 2013-12-03 00:29:32 -0500 )edit

I'm still getting: Undefined symbols for architecture x86_64: after Linking CXX shared library /Users/miRunner/ros_catkin_ws/devel_isolated/rqt_image_view/lib/librqt_image_view.dylib

iRunner gravatar image iRunner  ( 2013-12-03 03:13:59 -0500 )edit

Do you have find_package(OpenCV REQUIRED) in your CMakeLists.txt?

Artem gravatar image Artem  ( 2013-12-03 03:23:42 -0500 )edit

It should by default use c++11 but try adding set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -std=c++11 -stdlib=libc++ ")

Artem gravatar image Artem  ( 2013-12-03 03:24:28 -0500 )edit

nvm i got it to work after adding find_package(OpenCV required)

iRunner gravatar image iRunner  ( 2013-12-03 03:25:24 -0500 )edit

libc++ is used by default, but c++11 support is only active is your set the flag, not be default.

jensenb gravatar image jensenb  ( 2013-12-03 23:29:04 -0500 )edit

I follow the instructions and i get the next error Linking CXX shared library /Users/aslan/ros_catkin_ws/devel_isolated/robot_state_publisher/lib/librobot_state_publisher_solver.dylib Undefined symbols for architecture x86_64: "KDL::Tree::Tree(KDL::Tree const&)", referenced from: KDL::TreeFkSolverPosFull_recursive::TreeFkSolverPosFull_recursive(KDL::Tree const&) in treefksolverposfull_recursive.cpp.o

aslan gravatar image aslan  ( 2014-01-29 19:04:08 -0500 )edit

It might be easier to use curl and patch, for instance this is how I patched robot_model: `cd src && curl https://github.com/ros/robot_model/pull/43.diff | patch -p1; cd -`

William gravatar image William  ( 2014-02-24 10:11:45 -0500 )edit

When I cd src/orocos_kdl and then git remote add upstream git@github.com:orocos/orocos_kinematics_dynamics.git, I get "fatal: Not a git repository (or any of the parent directories): .git". Am I doing something wrong?

JetForMe gravatar image JetForMe  ( 2014-02-24 18:57:43 -0500 )edit

How did you create your hydro workspace? The error message indicates orocos_kdl was not checked out from source with wstool.

jensenb gravatar image jensenb  ( 2014-02-24 20:07:32 -0500 )edit
JetForMe gravatar image JetForMe  ( 2014-02-24 20:24:55 -0500 )edit

@jensenb you cannot assume that the src folder was created by checking out git repositories, it can also be extracted tarballs, that is why you should use the patch method, it works regardless.

William gravatar image William  ( 2014-02-25 07:43:38 -0500 )edit

@William I Understand, my mistake. But in general if you follow the installation guide on the wiki wstool will checkout git repositories released using bloom, right?

jensenb gravatar image jensenb  ( 2014-02-25 08:02:41 -0500 )edit

I don't think so, that was recently changed, because tar balls are much more efficient as a means of distribution. It has nothing to do with `wstool`, but instead is the `--tar` option to `rosinstall_generator`.

William gravatar image William  ( 2014-02-25 08:21:41 -0500 )edit

I'm having trouble with the roscpp fix, it returns -bash: syntax error near unexpected token `newline' Can someone double check the command?

rchapman gravatar image rchapman  ( 2014-02-25 09:35:27 -0500 )edit

I am having trouble with the OROCOS fix. When I run 'git fetch upstream' I get the following: "Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists." What could be going wrong here?

DevLan gravatar image DevLan  ( 2014-03-08 09:59:33 -0500 )edit

Ah ok, I had to make an RSA key for GitHub. Looks like I'm just bad at GitHub.

DevLan gravatar image DevLan  ( 2014-03-09 18:47:45 -0500 )edit

Thanks for the update!

Artem gravatar image Artem  ( 2014-03-12 03:56:05 -0500 )edit

I believe instead of cd <ros workspace="" dir="">/src it should be cd <ros workspace="" dir="">/src/orocos_kdl in the case of patching orocos_kdl and the same for robot_model.

Artem gravatar image Artem  ( 2014-03-12 04:31:11 -0500 )edit

No I am pretty sure the instructions are correct. The pull request patches are relative to the host repository, and since both orocos_kdl and robot_model are split so that each subdir becomes a new repository root, the patches have to be applied to WS_DIR/src and not one level deeper.

jensenb gravatar image jensenb  ( 2014-03-12 05:36:42 -0500 )edit
2

answered 2013-10-27 06:08:26 -0500

Artem gravatar image

updated 2013-11-14 17:03:40 -0500

The problem is caused by the tr1 prefix on the headers that is not supported in libc++. That is used in OSX 10.9.

The solution is to explicitly specify libstdc++ by adding the following lines to ./src/octomap/CMakeLists.txt and other corresponding CMakeLists.txt

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -stdlib=libstdc++")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}  -stdlib=libstdc++")
  • Edit this is not really a good solution as clang moving towards libc++.
edit flag offensive delete link more

Comments

Are you building with clang or gcc? Is that a standard flag that would be compatible with other compilers as well? Would you consider reporting this problem and a fix / pull request at the OctoMap upstream repo? https://github.com/OctoMap/octomap

AHornung gravatar image AHornung  ( 2013-10-27 23:13:05 -0500 )edit

I am building with clang. I will try to do a pull request later this week.

Artem gravatar image Artem  ( 2013-10-28 00:43:35 -0500 )edit

@AHornung adding those flags is not a good solution. The solution is to remove tr1 wherever it appears.

Artem gravatar image Artem  ( 2013-11-11 04:48:38 -0500 )edit

Removing the tr1 prefixes will probably break compilation for most other compilers that don't use tr1 by default... Probing for tr1 and then conditionally include the "right" stuff should work: http://www.cmake.org/pipermail/cmake/2013-January/053307.html

AHornung gravatar image AHornung  ( 2013-11-11 04:54:37 -0500 )edit

Yes it will break, it should be conditioned based on OS and compiler.

Artem gravatar image Artem  ( 2013-11-11 04:57:09 -0500 )edit

Didn't work for me. I continue to stop in "fatal error: 'tr1/unordered_set' file not found"

Bruno Normande gravatar image Bruno Normande  ( 2013-11-14 00:27:33 -0500 )edit
1

This just got fixed for OctoMap in the latest commit on the "devel" branch, if you check that out it should build fine: https://github.com/OctoMap/octomap

AHornung gravatar image AHornung  ( 2013-11-14 00:46:55 -0500 )edit

Question Tools

7 followers

Stats

Asked: 2013-10-27 06:06:49 -0500

Seen: 5,122 times

Last updated: Aug 05 '14