2015-12-08 86 views
0

我想在日食上设置增强库。我有 的Windows 7 Eclipse的月神 升压1.59 MinGW的日食增强库中的错误

我已经编译Boost库与B2命令。 我还为我的项目添加了路径和符号库。 在minGW链接器中,我有-L选项的“boostdir”\ stage \ lib路径。 在-l选项我尝试了很多 -boost_filesystem -boost_system 免 - 加强 -...

这里结合的问题是:

#include<iostream> 
#include <boost/math/distributions/chi_squared.hpp> 

int main() { 
double pvalue = 2.667; 
boost::math::chi_squared_distribution aDist(1); 
pvalue = boost::math::cdf(aDist,pvalue); 
std::cout << "The p-value is : "<<pvalue << std::endl; 
return 0; 

}

编译器给我:

16:24:25 **** Incremental Build of configuration Debug for project test2 **** 
Info: Internal Builder is used for build 
g++ "-IC:\\MinGW\\boost_1_59_0" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\test2.o" "..\\src\\test2.cpp" 
..\src\test2.cpp: In function 'int main()': 
..\src\test2.cpp:6:40: error: missing template arguments before 'aDist' 
    boost::math::chi_squared_distribution aDist(1); 
             ^
..\src\test2.cpp:6:40: error: expected ';' before 'aDist' 
..\src\test2.cpp:7:28: error: 'aDist' was not declared in this scope 
    pvalue = boost::math::cdf(aDist,pvalue); 
          ^

16:24:28 Build Finished (took 3s.531ms) 

第二个错误是确定的,因为它是由第6行造成的。 但是自动完成日食的作品,所以他可以以某种方式看到图书馆!

错误来自哪里?

回答

1

boost::math::chi_squared_distribution是一个类模板。你需要为它提供一个模板参数。例如,

boost::math::chi_squared_distribution<some_floating_point_type> mydist(1); 
+0

完美它解决了这个问题。我还需要在eclipse中删除并重新添加libaries,否则我会遇到另一个错误:未解决的模板候选项是:...或类似的东西。 – Eric