【发布时间】:2013-12-05 20:33:02
【问题描述】:
我有一个使用 VS2010 开发的应用程序,它使用 Boost.Thread 1.48。
目前我正在尝试将应用程序移植到 Linux(在 Debian 7 上运行)。
当我尝试使用 GCC 4.6 或 clang 编译它时,我收到以下错误
error: ‘class boost::mutex’ has no member named ‘timed_lock’
我必须设置任何预处理器定义或编译器标志吗?
编辑: 好的,我找到了问题。我使用了以下内容:
我的文件.h:
boost::mutex myMutex;
我的文件.cpp
if(myMutex.timed_lock(boost::posix_time::millisec(10000)))
{
// Do stuff
// ...
// ...
myMutex.unlock();
return true;
}
myMutex.unlock();
return false;
这适用于 VS2008/2010。 在 Linux 下,我不得不将标题更改为:
boost::timed_mutex myMutex;
我还是不太清楚,是什么原因。
【问题讨论】:
-
你在 Debian 中使用的是什么 boost 版本?
-
我从头开始构建 Boost 1.48 并指向包含 dir 和 lib dir。
标签: c++ linux gcc boost-thread