Boost C++ Libraries: Ticket #9848: flyweight: hidden dependency on pthread https://svn.boost.org/trac10/ticket/9848 <p> Hi, </p> <p> My application does not link properly on <a class="missing wiki">ArchLinux</a> (but out of the box on OS X and Ubuntu). For some reason, there I need -lpthread, and it appears that this requirement come from Flyweight. I could not find this dependency documented anywhere. Some clarification in the documentation would be most useful. </p> <p> Thanks. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9848 Trac 1.4.3 Joaquín M López Muñoz Mon, 07 Apr 2014 16:38:42 GMT <link>https://svn.boost.org/trac10/ticket/9848#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9848#comment:1</guid> <description> <p> Hi, </p> <p> The dependency stems from the usage of <code>boost::flyweights::simple_locking</code>: </p> <p> <a href="http://www.boost.org/libs/flyweight/doc/reference/locking.html#simple_locking">http://www.boost.org/libs/flyweight/doc/reference/locking.html#simple_locking</a> </p> <p> which takes advantage of the synchronization mechanisms available on the target environment. Your ArchLinux GCC distribution is configured in such a way that <code>BOOST_HAS_PTHREADS</code> is defined hence the need to link Pthreads with -lpthread. If you don't want to do the linking because your app is single-thread, you can either </p> <ul><li>use <code>boost::flyweights::no_locking</code> as the locking policy or </li><li>globally set the <code>BOOST_DISABLE_THREADS</code> macro. </li></ul><p> Please report back whether this clarifies the issue for you. Best, </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Tue, 08 Apr 2014 10:06:50 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9848#comment:2 https://svn.boost.org/trac10/ticket/9848#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket akim@… Tue, 08 Apr 2014 15:42:21 GMT <link>https://svn.boost.org/trac10/ticket/9848#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9848#comment:3</guid> <description> <p> Hi Joaquin, </p> <p> Thanks for the quick response. </p> <p> Actually, I already use no_locking in my project. Here is a small example: </p> <pre class="wiki">[forge@prague tmp]$ cat foo.cc #include &lt;boost/flyweight.hpp&gt; #include &lt;boost/flyweight/no_tracking.hpp&gt; using string = boost::flyweight&lt;std::string, boost::flyweights::no_tracking&gt;; int main() { string h{"Hello, World!"}; } [forge@prague tmp]$ clang++-3.4 -std=c++11 foo.cc /tmp/foo-856a4c.o:foo.cc:function boost::flyweights::detail::recursive_lightweight_mutex::recursive_lightweight_mutex(): error: undefined reference to 'pthread_mutexattr_init' /tmp/foo-856a4c.o:foo.cc:function boost::flyweights::detail::recursive_lightweight_mutex::recursive_lightweight_mutex(): error: undefined reference to 'pthread_mutexattr_settype' /tmp/foo-856a4c.o:foo.cc:function boost::flyweights::detail::recursive_lightweight_mutex::recursive_lightweight_mutex(): error: undefined reference to 'pthread_mutexattr_destroy' clang: error: linker command failed with exit code 1 (use -v to see invocation) </pre><p> Sure, it works with BOOST_DISABLE_THREADS, but then again, I have seen nothing about this in the documentation. A section on the dependencies would be helpful imho. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Tue, 08 Apr 2014 20:47:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9848#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9848#comment:4</guid> <description> <p> You're using <code>no_tracking</code>, not <code>no_locking</code>. </p> </description> <category>Ticket</category> </item> <item> <author>Akim Demaille <akim.demaille@…></author> <pubDate>Wed, 09 Apr 2014 13:50:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9848#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9848#comment:5</guid> <description> <p> Bwahaha! Thanks for pointing this out... </p> <p> (But still, don't you think dependencies such as pthreads etc. should be mentioned in the documentation?) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joaquín M López Muñoz</dc:creator> <pubDate>Thu, 10 Apr 2014 18:56:12 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/9848#comment:6 https://svn.boost.org/trac10/ticket/9848#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> Ticket Joaquín M López Muñoz Thu, 10 Apr 2014 18:56:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9848#comment:7 https://svn.boost.org/trac10/ticket/9848#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Added note on Pthreads dependency, see </p> <p> <a class="ext-link" href="https://github.com/boostorg/flyweight/commit/1ea709b6249cca1b7af33feed20d855c2d72542c"><span class="icon">​</span>https://github.com/boostorg/flyweight/commit/1ea709b6249cca1b7af33feed20d855c2d72542c</a> </p> Ticket akim@… Fri, 11 Apr 2014 06:57:31 GMT <link>https://svn.boost.org/trac10/ticket/9848#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9848#comment:8</guid> <description> <p> Great! Thanks a lot for Flyweights! </p> </description> <category>Ticket</category> </item> </channel> </rss>