boost库使用

boost C++库简介
linux下载安装

大部分库不需要编译,使用的时候只需要include相应的hpp文件即可,少数库需要提前编译。
假设下载的库文件解压到目录/path/to/boost
使用boost数学库中的expint函数(matlab)

#include "boost/math/special_functions/expint.hpp"
#include <iostream>

int main()
{
    using namespace boost::math;
    //matlab: x->expint(x)
    //boost:  x->-expint(-x)
    float x = -1.2;
    float y = (-1) * expint(x);
    std::cout << y << std::endl;
}

在Makefile增加boost的安装路径即可

BOOST_DIR = /path/to/boost
INCLUDE = -I$(BOOST_DIR)

猜你喜欢

转载自blog.csdn.net/xmdxcsj/article/details/70344696