2015-12-08 80 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