错误包括Boost线程库

时间:2015-09-07 15:51:37

标签: c++ multithreading boost compiler-errors

我有一个相当大的代码库,包括libSVM和lp_solve库。我最近在代码中添加了Boost Threading库,我继续得到一个我似乎无法解决的编译错误。

首先,我添加了线程库的include语句:

#include <boost/thread.hpp>

其次,我调整了makefile以进行编译。用于编译相关文件的命令是:

g++ -I./ -I../Eigen -I../Classification -I../Components -I../include 
-I../Individuals -I../Pruning -I../Pruning/AIS -I../Pruning/ACO 
-I../Pruning/GA -I../Pruning/PSO -I../Pruning/CFO -I../Random 
-I../Samplers -O2 -g -Wall -c -fmessage-length=0 -fopenmp -llpsolve55 
-lsvm -lboost_thread -lboost_system  -MMD -MP 
-MF"Samplers/OMPP_Sampler.d" -MT"Samplers/OMPP_Sampler.d" -o 
"Samplers/OMPP_Sampler.o" "../Samplers/OMPP_Sampler.cpp"

生成的错误是:

In file included from /usr/local/include/boost/thread.hpp:24,
             from ../Samplers/OMPP_Sampler.cpp:15:
/usr/local/include/boost/thread/future.hpp: In constructor 
‘boost::packaged_task<R>::packaged_task(R (*)())’:
/usr/local/include/boost/thread/future.hpp:3214: error: expected 
unqualified-id before numeric constant
/usr/local/include/boost/thread/future.hpp:3214: error: expected ‘)’ 
before numeric constant
/usr/local/include/boost/thread/future.hpp:3215: error: type/value 
mismatch at argument 1 in template parameter list for ‘template<class 
F, class R> struct boost::detail::task_shared_state’
/usr/local/include/boost/thread/future.hpp:3215: error:   expected a 
type, got ‘0’
/usr/local/include/boost/thread/future.hpp:3215: error: invalid type 
in declaration before ‘;’ token

我已经挖掘了Boost标头,尝试从我自己的代码中识别出任何重新定义等。导致问题的Boost代码如下:

explicit packaged_task(R(*f)())  
{
    typedef R(*FR)();
    typedef detail::task_shared_state<FR,R> task_shared_state_type;
    task= task_ptr(new task_shared_state_type(f));
    future_obtained=false;
}

关于如何解决这个问题的想法?

0 个答案:

没有答案