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 -0600

Artem gravatar image

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

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 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
10

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

jensenb gravatar image

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

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 -0600 )edit

how did you add opencv_libs into rqt_image_view CMakeLists.txt ?

iRunner gravatar image iRunner  ( 2013-12-02 19:15:02 -0600 )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 -0600 )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 -0600 )edit

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

Artem gravatar image Artem  ( 2013-12-03 03:23:42 -0600 )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 -0600 )edit

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

iRunner gravatar image iRunner  ( 2013-12-03 03:25:24 -0600 )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 -0600 )edit
2

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

Artem gravatar image

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

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 -0600 )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 -0600 )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 -0600 )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 -0600 )edit

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

Artem gravatar image Artem  ( 2013-11-11 04:57:09 -0600 )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 -0600 )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 -0600 )edit

Question Tools

7 followers

Stats

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

Seen: 5,208 times

Last updated: Aug 05 '14