title: Apple Mach-O Linker (ld) Error. ld: -r and -dead-strip cannot be used together
body: <p><strong><em>XCode 5.0.1</em></strong> is giving me an error after successful compilation of 161 C++ project files.
  <strong>There were many Apple Mach-O Linker Error questions but none helped me.</strong></p>
  
  <p>Message for the error is as following:</p>
  
  <pre><code>ld: -r and -dead_strip cannot be used together
  clang: error: linker command failed with exit code 1
   (use -v to see invocation)
  </code></pre>
  
  <p>The linking section in my build setting is in the following image:</p>
  
  <p><a href="https://i.stack.imgur.com/MPau9.png" rel="nofollow noreferrer">Linker Section of XCode 5.0.1</a></p>
  
  <p>Can anyone let me know how to solve this error?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>When I set    <code>Dead Code Stripping</code> to    <code>No</code> the then I get 19 Linking errors. <code>Mach-O Type</code> is set to <code>Dynamic Library</code> for both <code>Release</code> and <code>Debug</code>.
  Errors in this case are as following:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
        "boost::re_detail_106000::perl_matcher&lt;__gnu_cxx::__normal_iterator&lt;wchar    _t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;,     std::allocator&lt;wchar_t&gt; &gt; &gt;,     std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;wchar_t     const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;,     std::allocator&lt;wchar_t&gt; &gt; &gt; &gt; &gt;, boost::regex_traits&lt;wchar_t,     boost::cpp_regex_traits&lt;wchar_t&gt; &gt;     &gt;::construct_init(boost::basic_regex&lt;wchar_t,     boost::regex_traits&lt;wchar_t, boost::cpp_regex_traits&lt;wchar_t&gt; &gt; &gt; const&amp;,     boost::regex_constants::_match_flags)", referenced from:
        boost::re_detail_106000::perl_matcher&lt;__gnu_cxx::__normal_iterator&lt;wchar_    t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;,      std::allocator&lt;wchar_t&gt; &gt; &gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;wchar_t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;, std::allocator&lt;wchar_t&gt; &gt; &gt; &gt; &gt;, boost::regex_traits&lt;wchar_t, boost::cpp_regex_traits&lt;wchar_t&gt; &gt; &gt;::perl_matcher(__gnu_cxx::__normal_iterator&lt;wchar_t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;, std::allocator&lt;wchar_t&gt; &gt; &gt;, __gnu_cxx::__normal_iterator&lt;wchar_t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;, std::allocator&lt;wchar_t&gt; &gt; &gt;, boost::match_results&lt;__gnu_cxx::__normal_iterator&lt;wchar_t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;, std::allocator&lt;wchar_t&gt; &gt; &gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;wchar_t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;, std::allocator&lt;wchar_t&gt; &gt; &gt; &gt; &gt; &gt;&amp;, boost::basic_regex&lt;wchar_t, boost::regex_traits&lt;wchar_t, boost::cpp_regex_traits&lt;wchar_t&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator&lt;wchar_t const*, std::basic_string&lt;wchar_t, std::char_traits&lt;wchar_t&gt;, std::allocator&lt;wchar_t&gt; &gt; &gt;) in AdWrksTagDataFactory.o
  </code></pre>
  
  <p>And Error message as following:</p>
  
  <pre><code>ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>In some similar questions I had seen that this might be due to more than one versions of Boost, but I already checked that.</p>