XCode 5.0.1 is giving me an error after successful compilation of 161 C++ project files. There were many Apple Mach-O Linker Error questions but none helped me.
Message for the error is as following:
ld: -r and -dead_strip cannot be used together
clang: error: linker command failed with exit code 1
(use -v to see invocation)
The linking section in my build setting is in the following image:
Can anyone let me know how to solve this error?
UPDATE
When I set Dead Code Stripping
to No
the then I get 19 Linking errors. Mach-O Type
is set to Dynamic Library
for both Release
and Debug
.
Errors in this case are as following:
Undefined symbols for architecture x86_64:
"boost::re_detail_106000::perl_matcher<__gnu_cxx::__normal_iterator<wchar _t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > >::construct_init(boost::basic_regex<wchar_t, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > > const&, boost::regex_constants::_match_flags)", referenced from:
boost::re_detail_106000::perl_matcher<__gnu_cxx::__normal_iterator<wchar_ t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > >, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > >::perl_matcher(__gnu_cxx::__normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, __gnu_cxx::__normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, boost::match_results<__gnu_cxx::__normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > > >&, boost::basic_regex<wchar_t, boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > > const&, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > >) in AdWrksTagDataFactory.o
And Error message as following:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In some similar questions I had seen that this might be due to more than one versions of Boost, but I already checked that.
Just set Dead Code Stripping
to No
. When this option is set to Yes
Xcode will add the -dead_strip
flag during linking which is not supported when linking relocatable binaries.