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

[OGRE-499] Boost Thread-mt Linking problem on Mac 10.10 (yeosmite) #156

Closed
paroj opened this issue Nov 29, 2015 · 2 comments
Closed

[OGRE-499] Boost Thread-mt Linking problem on Mac 10.10 (yeosmite) #156

paroj opened this issue Nov 29, 2015 · 2 comments
Milestone

Comments

@paroj
Copy link
Member

paroj commented Nov 29, 2015

[reporter="wdavilaneto", created="Mon, 24 Aug 2015 06:52:11 +0200"]

Linking CXX shared library ../lib/macosx/Ogre.framework/Ogre
Undefined symbols for architecture x86_64:
"std::_1::vector_base_common::_throw_length_error() const", referenced from:
void std::_1::vector1::pair, std::1::allocator1::pair > >::push_back_slow_path1::pair const>(std::_1::pair const&) in libboost_thread-mt.a(thread.o)
void std::_1::vector, std::1::allocator > >::_push_back_slow_path const>(boost::shared_ptr const&) in libboost_thread-mt.a(thread.o)
"std::runtime_error::runtime_error(char const*)", referenced from:
boost::condition_variable::wait(boost::unique_lock&) in libboost_thread-mt.a(thread.o)
boost::condition_variable::do_wait_until(boost::unique_lock&, timespec const&) in libboost_thread-mt.a(thread.o)
boost::condition_variable::condition_variable() in libboost_thread-mt.a(thread.o)
boost::mutex::mutex() in libboost_thread-mt.a(thread.o)
boost::unique_lock::lock() in libboost_thread-mt.a(thread.o)
boost::mutex::lock() in libboost_thread-mt.a(thread.o)
boost::unique_lock::unlock() in libboost_thread-mt.a(thread.o)
...
"std::runtime_error::runtime_error(std::runtime_error const&)", referenced from:
void boost::throw_exception(boost::thread_resource_error const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl > boost::enable_current_exception >(boost::exception_detail::error_info_injector const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl >::clone() const in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl >::clone_impl(boost::exception_detail::clone_impl > const&) in libboost_thread-mt.a(thread.o)
void boost::throw_exception(boost::lock_error const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl > boost::enable_current_exception >(boost::exception_detail::error_info_injector const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl >::clone() const in libboost_thread-mt.a(thread.o)
...
"std::_1::basic_string1::char_traits, std::1::allocator >::_init(char const*, unsigned long)", referenced from:
boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
"std::_1::basic_string1::char_traits, std::_1::allocator >::append(char const*)", referenced from:
boost::system::system_error::what() const in libboost_thread-mt.a(thread.o)
"std::_1::basic_string1::char_traits, std::_1::allocator >::append(char const*, unsigned long)", referenced from:
boost::system::system_error::what() const in libboost_thread-mt.a(thread.o)
"std::_1::basic_string1::char_traits, std::_1::allocator >::assign(char const*)", referenced from:
boost::system::system_error::what() const in libboost_thread-mt.a(thread.o)
boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
"std::_1::basic_string1::char_traits, std::1::allocator >::basic_string(std::1::basic_string1::char_traits, std::_1::allocator > const&)", referenced from:
void boost::throw_exception(boost::thread_resource_error const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl > boost::enable_current_exception >(boost::exception_detail::error_info_injector const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl >::clone() const in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl >::clone_impl(boost::exception_detail::clone_impl > const&) in libboost_thread-mt.a(thread.o)
void boost::throw_exception(boost::lock_error const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl > boost::enable_current_exception >(boost::exception_detail::error_info_injector const&) in libboost_thread-mt.a(thread.o)
boost::exception_detail::clone_impl >::clone() const in libboost_thread-mt.a(thread.o)
...
"std::_1::basic_string1::char_traits, std::_1::allocator >::~basic_string()", referenced from:
boost::system::system_error::what() const in libboost_thread-mt.a(thread.o)
boost::condition_variable::wait(boost::unique_lock&) in libboost_thread-mt.a(thread.o)
boost::condition_variable::do_wait_until(boost::unique_lock&, timespec const&) in libboost_thread-mt.a(thread.o)
boost::system::system_error::~system_error() in libboost_thread-mt.a(thread.o)
boost::system::system_error::~system_error() in libboost_thread-mt.a(thread.o)
boost::condition_variable::condition_variable() in libboost_thread-mt.a(thread.o)
void boost::throw_exception(boost::thread_resource_error const&) in libboost_thread-mt.a(thread.o)
...
"std::bad_alloc::bad_alloc()", referenced from:
boost::exception_ptr boost::exception_detail::get_static_exception_object() in libboost_thread-mt.a(thread.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/macosx/Ogre.framework/Versions/1.10.0/Ogre] Error 1
make[1]: *** [OgreMain/CMakeFiles/OgreMain.dir/all] Error 2
make: *** [all] Error 2

@bowang
Copy link

bowang commented Jan 9, 2016

The source of your problem is due to the deviation of libc++ from libstdc++ (details can be found on http://libcxx.llvm.org)
Since OS X 10.9, Apple uses its own version of C++ library, i.e. libc++, with its clang compiler by default, rather than the standard libstdc++ from GNU.

However, in CMakeList.txt, the deployment target is set to 10.7, i.e.

  # 10.7 is the minimum for libc++ support
  set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)

The parameter CMAKE_OSX_DEPLOYMENT_TARGET is propagated into the compilation argument as '-mmacosx-version-min=10.7'

In OS X 10.7, the default C++ library was still libstdc++. Thus, clang attempts to link OGRE against libstdc++. Meanwhile, the boost library on your Mac OSX has been updated and is built with libc++, which you can confirm with otool as follow:

otool -L /usr/local/lib/libboost_system.dylib

Therefore, the linker cannot find the libc++ library required by boost.

Solution: in short, build OGRE targeting at your OS X version (i,e, 10.10) by correcting CMAKE_OSX_DEPLOYMENT_TARGET.

  set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)

@paroj
Copy link
Member Author

paroj commented Jan 16, 2016

thanks for your explanation. However on the CI server this currently only triggers a warning - it seems that the newer Xcode/ CMake handles this correctly now. See:
https://travis-ci.org/OGRECave/ogre/jobs/102723959#L2086

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

No branches or pull requests

2 participants