#9848 closed Bugs (fixed)
flyweight: hidden dependency on pthread
Reported by: | Owned by: | Joaquín M López Muñoz | |
---|---|---|---|
Milestone: | To Be Determined | Component: | flyweight |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Hi,
My application does not link properly on ArchLinux (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.
Thanks.
Change History (8)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 by , 9 years ago
Hi Joaquin,
Thanks for the quick response.
Actually, I already use no_locking in my project. Here is a small example:
[forge@prague tmp]$ cat foo.cc #include <boost/flyweight.hpp> #include <boost/flyweight/no_tracking.hpp> using string = boost::flyweight<std::string, boost::flyweights::no_tracking>; 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)
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.
comment:5 by , 9 years ago
Bwahaha! Thanks for pointing this out...
(But still, don't you think dependencies such as pthreads etc. should be mentioned in the documentation?)
comment:6 by , 9 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
comment:7 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Added note on Pthreads dependency, see
https://github.com/boostorg/flyweight/commit/1ea709b6249cca1b7af33feed20d855c2d72542c
Hi,
The dependency stems from the usage of
boost::flyweights::simple_locking
:http://www.boost.org/libs/flyweight/doc/reference/locking.html#simple_locking
which takes advantage of the synchronization mechanisms available on the target environment. Your ArchLinux GCC distribution is configured in such a way that
BOOST_HAS_PTHREADS
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 eitherboost::flyweights::no_locking
as the locking policy orBOOST_DISABLE_THREADS
macro.Please report back whether this clarifies the issue for you. Best,