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

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 -0600 )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 -0600 )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 -0600 )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 -0600 )edit
JetForMe gravatar image JetForMe  ( 2014-02-24 20:24:55 -0600 )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 -0600 )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 -0600 )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 -0600 )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 -0600 )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 -0600 )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 -0600 )edit

Thanks for the update!

Artem gravatar image Artem  ( 2014-03-12 03:56:05 -0600 )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 -0600 )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 -0600 )edit

Take a look at the patch files in your browser and you will see what I mean.

jensenb gravatar image jensenb  ( 2014-03-12 05:37:14 -0600 )edit

Big thumbs up for the updated instructions. Thanks!

demmeln gravatar image demmeln  ( 2014-03-12 07:19:26 -0600 )edit

I, too, have to cd to workspace/src/orocos_kdl. My install is some part of the way through, and I don't remember where I left off. CDing into the orocos_kdl directory and applying the patch, it warns it's already been applied. Not sure how to proceed.

JetForMe gravatar image JetForMe  ( 2014-03-12 10:54:26 -0600 )edit

Huh. I don't seem to have a kdl_parser at all. Perhaps I should start over. Can someone point me at the correct set of instructions to start with? I'm seen so many different things, I'm not sure any more.

JetForMe gravatar image JetForMe  ( 2014-03-12 10:57:07 -0600 )edit

The warning means you already applied the first change, meaning you have the orocos_kdl upstream version per the previous instructions. If you delete this directory from WS_DIR/src and do 'wstool update -t WD_DIR/src', you should get a clean copy and so that you can apply the steps from the answer.

jensenb gravatar image jensenb  ( 2014-03-12 11:22:00 -0600 )edit

You can also do the same thing for the WS_DIR/src/robot_model directory. If all else fails, simply create a new separate ROS workspace and follow the current Hydro installation instructions again, and the steps above should cover all the current build issues.

jensenb gravatar image jensenb  ( 2014-03-12 11:26:55 -0600 )edit

So, I deleted the WS_DIR/src/orocos_kdl directory, ran wstool, and I still get a WS_DIR/src/orocos_kdl/orocos_kdl, and can't apply the patch from WS_DIR/src ("can't find file to patch at input line 30").

JetForMe gravatar image JetForMe  ( 2014-03-12 11:49:20 -0600 )edit

@jensenb: I suspect you havent updated rosinstall_generator recently. There has been a change to group the packages by repository. So for the current rosinstall_generator you have to go in the corrsponding subfolder for robot_model and orocos_kdl.

demmeln gravatar image demmeln  ( 2014-03-15 03:55:50 -0600 )edit

@JetForMe: See above comment about updated rosinstall_generator. Start over and either use the --flat option for rosinstall_generator (this will go back to the old behaviour of not putting the repos in a subfolder, for which the above instructions should work) or go into the subfolders for patching.

demmeln gravatar image demmeln  ( 2014-03-15 03:58:37 -0600 )edit

Lastly, there has recently been a patch to boost to fix issues with the new clang version that recently came as an apple update. You might need to `brew reinstall boost`.

demmeln gravatar image demmeln  ( 2014-03-15 04:00:22 -0600 )edit

@demmeln, @Artem: You are right after all, I had not updated my rosinstall_generator for a while and so I didn't see the package regrouping, my mistake. I have updated the answer accordingly.

jensenb gravatar image jensenb  ( 2014-03-16 22:56:22 -0600 )edit

I tweaked the answer slightly for current state of things.

demmeln gravatar image demmeln  ( 2014-04-08 07:10:16 -0600 )edit

Trying from scratch with the latest, I get boost errors while building class_loader: http://pastebin.com/isZS3LAb I also had one issue with the first patch: http://pastebin.com/HYkZiMiL

JetForMe gravatar image JetForMe  ( 2014-04-08 08:57:24 -0600 )edit

For the class_loader issue I believe you have to reinstall boost: `brew update && brew upgrade boost`. And issue I see as well, but it doesn't stop you from building.

demmeln gravatar image demmeln  ( 2014-04-08 09:30:36 -0600 )edit

orocos_kinematics_dynamics still fails "ImportError: No module named sipconfig": http://pastebin.com/NvhVmgZ4

JetForMe gravatar image JetForMe  ( 2014-04-08 11:03:02 -0600 )edit

@JetForMe your pastebin links are invalid, can you update them?

jensenb gravatar image jensenb  ( 2014-04-08 11:22:57 -0600 )edit

Strange. It's converting them when I paste. Another try: http://pastebin.com/NvhVmgZ4 I'm doing something wrong, but perhaps you can copy and paste the text as it appears?

JetForMe gravatar image JetForMe  ( 2014-04-08 11:40:19 -0600 )edit

Seems to be a bug in AskBot. A link (http://pastebin.com/NvhVmgZ4) in the middle is implied to work. The link (http://pastebin.com/HYkZiMiL) to my earlier pastebin, for ease. Sorry for all the noise.

JetForMe gravatar image JetForMe  ( 2014-04-08 11:43:48 -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,211 times

Last updated: Aug 05 '14