c++ - eclipse boost 库出错

标签 c++ eclipse boost

我正在尝试在我的 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/

相关文章:

java - NetBeans 或 Eclipse 中货币符号的快捷方式

c++ - 如何从配置中设置 boost 日志记录严重性级别?

c++ - 如何删除这种二维数组?

java - 安装的 JRE/JDK 未显示在 Eclipse Mars 的执行环境中

c++ - 无法使用 gprof 累积时间 - gnu 分析器

visual-studio - 我不明白 Visual Studio 项目和解决方案的概念

c++ - 自定义 STL 序列的最小嵌套 typedef 集?

c++ - 可移植线程 API

安卓 NDK : How to replace AAsset to work with files from external Storage for FFmpeg decoding

c++ - 将函数加好友时出错