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

c++11 with ROS on OSX

asked 2013-09-10 01:29:04 -0600

Markus Achtelik gravatar image

Hi all,

we have some packages developed with c++11 features, which was no problem on Ubuntu. We'd like to use it on osx now as well, which seems to be harder than we thought. From what I understood so far, clang (shipped with the latest version of Xcode) does support c++11, when using the -stdlib=libc++ flag. However, this causes issues (especially std::string) when linking against libstdc++, which is the case for all homebrew-built libraries and for ROS by default as well. Linking is fine, but runtime crashes occur whenever std objects are passed between the libraries.

As libstdc++ seems not to be further developed, the cleanest solution would probably be to get homebrew to use libc++. There is a discussion about it here: https://github.com/mxcl/homebrew/issues/9314 . However, it seems like this is not going to move forward soon.

We could now start fixing the homebrew dependencies to use libc++, but that would most likely cause issues with some other libs built against libstdc++ ...

Any idea or thought to work around this? Or am I missing anything? I'd dislike porting back all our c++11 code.

Thanks a lot, Markus

edit retag flag offensive close merge delete

Comments

This is probably out of the scope of ROS answers, this will involve setting up your system to build using `libc++` for everything. As @joq pointed out, we haven't committed to explicitly supporting c++11 in ROS, but it sounds like to me it works on Linux? Anyways if you find out how to manage this on OS X or find more details into what is causing the issues let me know.

William gravatar image William  ( 2013-09-10 07:55:11 -0600 )edit

I thought it would be worth discussing it here as well. c++11 works fine for us under linux since gcc 4.6 if I remember it correct. I just checked, it links to libstdc++. However, it seems quite old on osx. I'll let you know when I find something out,but I'm almost giving up on this for near future.

Markus Achtelik gravatar image Markus Achtelik  ( 2013-09-11 06:28:54 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-09-10 04:58:45 -0600

joq gravatar image

Given all the ABI incompatibilities that come with any new C++ version, the ROS policy is the one described in REP-0003, which says:

Use of C++[0|1]x or tr1 features are only allowed if support for that 
feature is checked at compile time, and equivalent functionality exists
without requiring C++[0|1]x code. A wholesale jump to C++[0|1]x will not
happen until all commonly used OS platforms fully support it.

I understand your reluctance to back-port your code, but if you want it to work on non-OSX platforms, some kind of conditional compilation will be necessary.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-09-10 01:29:04 -0600

Seen: 1,317 times

Last updated: Sep 10 '13