Boost C++ Libraries: Ticket #8448: thread library needs linking against -lrt https://svn.boost.org/trac10/ticket/8448 <p> I have a similar problem to one described here: <a class="ext-link" href="http://stackoverflow.com/questions/14835605/linking-with-gcc-fails-after-switching-boost-version-from-1-52-to-1-53"><span class="icon">​</span>http://stackoverflow.com/questions/14835605/linking-with-gcc-fails-after-switching-boost-version-from-1-52-to-1-53</a> </p> <p> I'm able to fix it by adding -lrt in my build system, but I guess it's a bug in boost build system - if boost needs -lrt, it should have been already linked against it, right? </p> <p> I build boost like this: </p> <pre class="wiki">./bootstrap.sh --without-icu ./b2 toolset=gcc variant=release link=static threading=multi runtime-link=shared --with-system --with-filesystem --with-test --with-thread --prefix=/some/path install </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8448 Trac 1.4.3 viboes Tue, 16 Apr 2013 17:11:38 GMT status, component changed; owner set https://svn.boost.org/trac10/ticket/8448#comment:1 https://svn.boost.org/trac10/ticket/8448#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">Building Boost</span> → <span class="trac-field-new">chrono</span> </li> </ul> <p> On what platform are you building? Which error do you get? </p> Ticket Maciej Sokołowski <matemaciek@…> Wed, 17 Apr 2013 05:29:50 GMT <link>https://svn.boost.org/trac10/ticket/8448#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8448#comment:2</guid> <description> <p> Exact output: </p> <pre class="wiki">/[...]/boost/1_53_0/linux64.gcc-4.7/libboost_thread.a(thread.o): In function `boost::this_thread::hiden::sleep_for(timespec const&amp;)': thread.cpp:(.text+0xc48): undefined reference to `clock_gettime' /[...]/boost/1_53_0/linux64.gcc-4.7/libboost_thread.a(thread.o): In function `boost::this_thread::hiden::sleep_until(timespec const&amp;)': thread.cpp:(.text+0x14b6): undefined reference to `clock_gettime' thread.cpp:(.text+0x1525): undefined reference to `clock_gettime' thread.cpp:(.text+0x1594): undefined reference to `clock_gettime' thread.cpp:(.text+0x1603): undefined reference to `clock_gettime' /home/msokolowski/gg_repos/phoenix-common/ggclient-3rdparty/boost/1_53_0/linux64.gcc-4.7/libboost_thread.a(thread.o):thread.cpp:(.text+0x1672): more undefined references to `clock_gettime' follow collect2: error: ld returned 1 exit status </pre> </description> <category>Ticket</category> </item> <item> <author>Maciej Sokołowski <matemaciek@…></author> <pubDate>Wed, 17 Apr 2013 05:32:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8448#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8448#comment:3</guid> <description> <p> uname -a: </p> <pre class="wiki">Linux KOMUNIKATOR-11 3.5.0-26-generic #42-Ubuntu SMP Fri Mar 8 23:18:20 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux </pre><p> gcc 4.7.2, platfrom: Ubuntu 12.10 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 17 Apr 2013 06:31:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8448#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8448#comment:4</guid> <description> <p> The Boost.Chrono build Jamfile contains </p> <pre class="wiki"> : requirements &lt;target-os&gt;freebsd:&lt;linkflags&gt;"-lrt" &lt;target-os&gt;linux:&lt;linkflags&gt;"-lrt -lpthread" &lt;toolset&gt;pgi:&lt;linkflags&gt;"-lrt" </pre><p> Are you linking with boost_chrono? Could you show the link command line? </p> </description> <category>Ticket</category> </item> <item> <author>Maciej Sokołowski <matemaciek@…></author> <pubDate>Wed, 17 Apr 2013 06:57:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8448#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8448#comment:5</guid> <description> <p> I'm not linking with boost_chrono (should I? why?): </p> <pre class="wiki">/usr/bin/c++ -pedantic -Wall -g [a bunch of our .o files here] -o outputFile -rdynamic /boost/path/libboost_filesystem.a /boost/path/libboost_system.a /boost/path/libboost_thread.a </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 17 Apr 2013 16:42:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8448#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8448#comment:6</guid> <description> <p> If you don't want to use the time related functions based on Boost.Chrono you can define BOOST_THREAD_DONT_USE_CHRONO. From Boost.Thread documentation: </p> <pre class="wiki">Boost.Chrono Boost.Thread uses by default Boost.Chrono for the time related functions and define BOOST_THREAD_USES_CHRONO if BOOST_THREAD_DONT_USE_CHRONO is not defined. The user should define BOOST_THREAD_DONT_USE_CHRONO for compilers that don't work well with Boost.Chrono. </pre><p> Otherwise you need to link with it, or define the macros needed to make Boost.Chrono header only. From Boost.Chrono documentation: </p> <pre class="wiki">Building Boost.Chrono Boost.Chrono can be configured as a header-only library defining BOOST_CHRONO_HEADER_ONLY. However Boost.Chrono depends on the non header-only library Boost.System, so that you will need to link with boost_system. Boost.System has un undocumented feature (use of macro BOOST_ERROR_CODE_HEADER_ONLY) to make it header only, but it is buggy (see #7347 duplicate symbol while BOOST_ERROR_CODE_HEADER_ONLY is defined) If BOOST_CHRONO_HEADER_ONLY is not defined you need to compile it and build the library before use, for example using: bjam libs/chrono/build </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 19 Apr 2013 16:23:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8448#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8448#comment:7</guid> <description> <p> Could I close this ticket? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 21 Apr 2013 07:40:28 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8448#comment:8 https://svn.boost.org/trac10/ticket/8448#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket