Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on OSX 10.9 #307

Closed
hgaiser opened this issue Oct 28, 2013 · 8 comments
Closed

Building on OSX 10.9 #307

hgaiser opened this issue Oct 28, 2013 · 8 comments
Labels

Comments

@hgaiser
Copy link
Contributor

hgaiser commented Oct 28, 2013

Hi,

When building rosconsole on OSX 10.9 it gives the following undefined references:

/usr/local/Cellar/cmake/2.8.12/bin/cmake -E cmake_link_script CMakeFiles/rosconsole.dir/link.txt --verbose=1
/usr/bin/c++  -stdlib=libstdc++  -stdlib=libstdc++ -dynamiclib -Wl,-headerpad_max_install_names   -o /opt/ros/hydro/devel_isolated/rosconsole/lib/librosconsole.dylib -install_name /opt/ros/hydro/devel_isolated/rosconsole/lib/librosconsole.dylib CMakeFiles/rosconsole.dir/src/rosconsole/rosconsole.cpp.o /opt/ros/hydro/install_isolated/lib/libcpp_common.dylib /opt/ros/hydro/install_isolated/lib/librostime.dylib /usr/local/lib/libboost_date_time-mt.dylib /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libboost_thread-mt.dylib /usr/local/lib/liblog4cxx.dylib /usr/local/lib/libboost_regex-mt.dylib /usr/local/lib/libboost_thread-mt.dylib /usr/local/lib/liblog4cxx.dylib /usr/local/lib/libboost_regex-mt.dylib 
Undefined symbols for architecture x86_64:
  "ros::operator<<(std::ostream&, ros::Time const&)", referenced from:
      ros::console::TimeToken::getString(log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> const&) in rosconsole.cpp.o
  "ros::operator<<(std::ostream&, ros::WallTime const&)", referenced from:
      ros::console::TimeToken::getString(log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggingEvent> const&) in rosconsole.cpp.o
  "boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)", referenced from:
      boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>) in rosconsole.cpp.o
  "boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::find()", referenced from:
      bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<char const*, std::string>) in rosconsole.cpp.o
ld: symbol(s) not found for architecture x86_64

For getting this far I had to manually compile log4cxx to use libstdc++ instead of libc++.

Best regards,
Hans

@dirk-thomas
Copy link
Member

@wjwwood Any idea?

@hgaiser
Copy link
Contributor Author

hgaiser commented Oct 29, 2013

Sorry, should have mentioned it, but this comes from this answers.ros.org topic:

http://answers.ros.org/question/95056/building-rosconsole-osx-109/

@wjwwood
Copy link
Member

wjwwood commented Oct 29, 2013

@dirk-thomas nope, I haven't yet had the time to update to 10.9, I'll try to look into this as soon as I can reproduce it and I have time.

@hgaiser
Copy link
Contributor Author

hgaiser commented Oct 31, 2013

I have compiled rosconsole by now. I had to install the latest brew of boost and recompile log4cxx using this brew scheme : Homebrew/legacy-homebrew#23798

I also had to compile octomap without libstdc++ (so I had to fix some includes and namespaces that had changed).

As a general note, many ros packages now fail due to the use of libc++ instead of libstdc++ because of forward declaring classes, something like this :

class A;
typedef std::vector AMap;

class A{
};

will now fail on libc++. The vector requires a defined type since some version and thus it should be something like std::vector<A*> or std::vectorstd::unique_ptr

This sort of errors seem to happen in multiple ros packages, for now I am just simply adding these cmake arguments:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libstdc++")

@hgaiser hgaiser closed this as completed Oct 31, 2013
@venabled
Copy link

venabled commented Nov 6, 2013

Just a follow up from the macports side, with the move to the new command line tools it looks like XCode is defaulting to libc++ by default (different behavior than before) so there's some issues. This thread was very useful helping us debug.

@hgaiser
Copy link
Contributor Author

hgaiser commented Nov 6, 2013

I am happy to hear that.

Do you mean that some macports installations now use libstdc++ to compile though? Because I had gotten nothing but trouble actually, compiling some libraries with libstdc++ and others with libc++. Eventually I managed to get it all to compile using libc++, which I think should be the preference for OSX 10.9+

@venabled
Copy link

venabled commented Nov 7, 2013

@hgaiser The big issue is that by default, 10.9 uses libc++ for all the ports it installs. In order to get some of the ports to build, we were using macports' gcc, which only links against libstdc++, so we were eventually running into the issues you mention.

RIght now we're having some issues trying to get roscpp to compile with clang/libc++, but we can talk about those offline if you want to.

@hgaiser
Copy link
Contributor Author

hgaiser commented Nov 7, 2013

Perhaps this will help you :
ros/roscpp_core#15

For further discussions you can contact me, perhaps I am able to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants