我正在尝试在我的 eclipse 上设置 boost 库。我有 Windows 7的 eclipse 月神 boost 1.59 铭文
我已经用 b2 命令编译了 boost 库。 我还在我的项目的路径和符号中添加了库。 在 minGW 链接器中,我有 -L 选项的“boostdir”\stage\lib 路径。 在 -l 选项中,我尝试了很多组合 -boost_filesystem -boost_system - boost -...
问题是:
#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 行引起的。 但是 eclipse 的自动完成工作,所以他可以以某种方式看到图书馆!
错误从何而来?
最佳答案
boost::math::chi_squared_distribution
是一个类模板。您需要为其提供一个模板参数。例如,
boost::math::chi_squared_distribution<some_floating_point_type> mydist(1);
关于c++ - eclipse boost 库出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34166145/