I am compiling a project. It has the following lines :
boost::mutex::scoped_lock ml(m_meta_mut, boost::defer_lock);
boost::mutex::scoped_lock tl(m_tables_mut, boost::defer_lock);
boost::lock(ml, tl);
I am getting lock is not a member of boost
on the third line. I am using boost1.53 (the project recommends 1.49)
What is the problem
Turning my comment into more of a complete answer. The boost::lock()
functions are defined in boost/thread/locks.hpp. When you see the compiler error
error: ‘lock’ is not a member of ‘boost’
the compiler cannot find a function lock()
in the boost
namespace.
The solution is to add #include <boost/thread/locks.hpp>
in whatever translation unit you are compiling.
I don't see changes to this header from boost 1.49 to boost 1.53, though I didn't look extensively. It's possible include directives have changed.
Edit: Still the same in 1.67
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With