Boost C++ Libraries: Ticket #6903: Including program options header breaks using g++ -static -flto -std=c++11 https://svn.boost.org/trac10/ticket/6903 <p> A minimal example is simply </p> <pre class="wiki">#include "boost/program_options.hpp" int main ( int argC, char* argV[] ) { return 0; } </pre><p> Compiling this using either<br /> g++ main.cpp -static -flto -std=c++11 -fwhole-program<br /> or<br /> g++ main.cpp -static -flto -std=c++11 -fno-use-linker-plugin<br /> gives a lot of errors: </p> <p> `_ZTIN9<span class="underline">gnu_cxx24</span>concurrence_lock_errorE' referenced in section `.text._ZN9<span class="underline">gnu_cxx30</span>throw_concurrence_lock_errorEv[_ZN9<span class="underline">gnu_cxx30</span>throw_concurrence_lock_errorEv]' of /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.a(eh_alloc.o): defined in discarded section `.gnu.linkonce.t._ZTIN9<span class="underline">gnu_cxx24</span>concurrence_lock_errorE' of /tmp/ccEoPVoT.o (symbol from plugin)<br /> ...<br /> collect2: error: ld returned 1 exit status </p> <p> I tried g++4.6 and 4.7. I am not sure if it is a bug within the g++ or within boost. If either -static, -flto or -std=c++11 is omited the program compiles fine. Only if all three are present the error occours. I am using Debian Wheezy. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6903 Trac 1.4.3 anonymous Fri, 01 Jun 2012 17:26:42 GMT <link>https://svn.boost.org/trac10/ticket/6903#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6903#comment:1</guid> <description> <p> I have a similar problem linking statically with -flto and -std=gnu++0x </p> <p> <code>typeinfo for boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::bad_weak_ptr&gt; &gt;' referenced in section </code>.text._ZNK5boost16exception_detail10clone_implINS0_19error_info_injectorINS_12bad_weak_ptrEEEE7rethrowEv[boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::bad_weak_ptr&gt; &gt;::rethrow() const]' of /home/bsun/phoenix/opt/cpplibraries/boost/1_49_0/lib/gcc-4.6/libboost_thread-mt-s.a(thread.o): defined in discarded section `.gnu.linkonce.t._ZTIN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_12bad_weak_ptrEEEEE' of ./src/test/router.o (symbol from plugin) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 14 Jun 2012 12:28:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6903#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6903#comment:2</guid> <description> <p> I have the same problem: g++-4.7 only, but event without -flto this error appears... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 23 Oct 2012 17:47:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6903#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6903#comment:3</guid> <description> <p> Which binutils version did you use? Which flags did you set to compile boost. IMO -flto must be passed when compiling boost libs if I correctly understand the docs: </p> <p> gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 24 Oct 2012 20:37:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6903#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6903#comment:4</guid> <description> <p> created a gcc 4.7.1 build on debian squeeze using crosstool-ng and mostly latest versions of all required libs resulted in no errors. A small Note: I compiled boost, icu, zlib, bzlib with -flto flag as well. </p> </description> <category>Ticket</category> </item> </channel> </rss>