linux CentOS7系统如何升级boost库?

linux CentOS7系统如何升级boost库?,第1张

直接重新下载安装即可

1.下载 boost

2. 将文件解压在/usr/local/目录

3. 进入/usr/local/boost/ 目录, 在terminal中输入

./bootstrap.sh

4.进入/usr/local/boost/ 目录,在terminal中输入

sudo ./bjam --layout=versioned --build-type=complete --toolset=gcc install

5.添加环境变量(刚改完要重启或者注销一下来更新刚修改过的环境变量)

两种方法:

(1)修改/etc/profie文件 末尾添加

export BOOST_INCLUDE=/usr/local/include/boost

export BOOST_LIB=/usr/local/lib

(2)在/etc/profile.d/ 中新建一个shell文件boost.sh

#!/bin/sh

export BOOST_INCLUDE=/usr/local/include/boost

export BOOST_LIB=/usr/local/lib

我系统是ubuntukylin14.04

然后今天去BOOST下了最新版的boost1.57版

下载下来的压缩文件我解压到/opt目录下即/opt/boost_1_57_0

然后

cd /opt/boost_1_57_0

./boststrap

./b2

这里b2命令执行完成后显示:

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

/opt/boost_1_57_0

The following directory should be added to linker library paths:

/opt/boost_1_57_0/stage/lib

然后我找了一段例子

C/C++ code?

1

2

3

4

5

6

7

8

9

10

#include<iostream>

#include<boost/bind.hpp>

using namespace std

using namespace boost

int fun(int x,int y){return x+y}

int main(){

int m=1int n=2

cout<<boost::bind(fun,_1,_2)(m,n)<<endl

return 0

}

用g++编译的时候提示

bst.cxx:2:31: fatal error: boost/bind.hpp: 没有那个文件或目录

#include<boost/bind.hpp>

^

compilation terminated.


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7281634.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-03
下一篇2023-04-03

发表评论

登录后才能评论

评论列表(0条)

    保存