【发布时间】:2015-02-16 01:56:39
【问题描述】:
我有一个小测试用例程序,只是为了查看 boost 是否适用于某些系统。
#include <iostream>
#include <boost/math/distributions/normal.hpp>
#include <boost/math/distributions/chi_squared.hpp>
using namespace std;
int main(int argc, char* argv[]) {
// Boost test
boost::math::normal std_normal;
double x = 1.5;
cout << boost::math::cdf(std_normal, x) << endl;
boost::math::normal non_std_normal(1.5, 2);
cout << boost::math::cdf(non_std_normal, x) << endl; // should output 1/2
// Test the chi-squared inverse
int degree_of_freedom = 19;
boost::math::chi_squared chi_dist(degree_of_freedom);
cout << boost::math::quantile(complement(chi_dist, 0.05)) << endl;
return 0;
}
我 ssh 到某个服务器,它们只允许我通过一些充满共享对象和存档文件(即 libboost_log.so、libboost_math_c99.a 等)的目录使用 boost 库。
说实话,我不知道如何使用这些文件。 我试过(对于 g++ 和 gcc)
g++ test.cpp -o test -l /share/apps/boost/1.55.0/lib
g++ test.cpp -o test -l /share/apps/boost/1.55.0/lib -lboost_system -lboost_filesystem
g++ -std=c++11 -pedantic test.cpp -I/share/apps/boost/1.55.0/include/ -o test
g++ test.cpp -o test -I /share/apps/boost/1.55.0/include -lboost_system -lboost_filesystem
其中 /share/apps/boost/1.55.0/lib 是 .so 和 .a 文件的目录 /share/apps/boost/1.55.0/include 是 .hpp 文件的目录。
我被拒绝使用第三个命令的权限,输出如下:
在包含的文件中 /share/apps/boost/1.55.0/include/boost/math/special_functions/detail/round_fwd.hpp:11:0, 来自/share/apps/boost/1.55.0/include/boost/math/special_functions/math_fwd.hpp:26, 来自/share/apps/boost/1.55.0/include/boost/math/special_functions/erf.hpp:13, 来自/share/apps/boost/1.55.0/include/boost/math/distributions/normal.hpp:19, 来自 test.cpp:12: /share/apps/boost/1.55.0/include/boost/config.hpp:30:29: 致命错误: /share/apps/boost/1.56.0/build/boost_1_56_0/boost/config/user.hpp: 权限被拒绝
我收到第四个命令的错误:
致命错误:boost/math/distributions/normal.hpp:没有这样的文件或 目录。
【问题讨论】:
-
您应该使用 -L 作为库路径,但您确实需要您可以阅读标题。
-
看起来我有权阅读它......我不确定问题是什么:/。我尝试直接 #include "/share/apps/boost/1.55.0/include/boost/math/..." 但它不起作用,因为它引用了另一个带有 #include
-
你能在目标机器上自己编译boost并链接到你自己的共享库吗?或者可以复制在您的主工作站上编译的文件?
-
是的。我最初的计划只是在我的工作站上编译然后在服务器上执行我的程序,但是我收到以下错误:./scrub: error while loading shared libraries: libboost_program_options.so.1.54.0: cannot open shared object file:没有这样的文件或目录但我不确定我是否理解你的第一个问题。对不起,我作为程序员有点缺乏经验。