当前位置:首页 » 操作系统 » boost安装linux

boost安装linux

发布时间: 2022-05-11 13:38:25

1. 在linux上运行boost库的问题

我系统是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=1;int 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.

2. 在linux系统下,安装boost.python库时问题求解

你把这个mole 重新安装在python目录下,或者在path里把mole所在目录添加上。。。

3. 电脑直接安装了linux操作系统,使用kdevelop编程,现在需要用到boost库。可是一直配置不上,求大神帮忙

sudoapt-getinstalllibboost-all-dev

然后包括boost的头文件在你的代码里就好了。boost是模版库,大部分不需要链接库的。

4. Linux 系统下如何安装使用 Boost库

http://wenku..com/view/57cbbd422af90242a995e530.html

5. linux下的boost库的安装方法是什么

打开synaptic, 找到libboost-all-dev, 安装即可。

安装后可以查看boost相关库,在/usr/lib/目录下

如:/usr/lib/libboost_date_time.a /usr/lib/libboost_math_tr1f-mt.a /usr/lib/libboost_serialization-mt.so

/usr/lib/libboost_date_time-mt.a /usr/lib/libboost_math_tr1f-mt.so /usr/lib/libboost_serialization.so

/usr/lib/libboost_date_time-mt.so /usr/lib/libboost_math_tr1f.so /usr/lib/libboost_serialization.so.1.42.0

/usr/lib/libboost_date_time.so /usr/lib/libboost_math_tr1f.so.1.42.0 /usr/lib/libboost_signals.a

/usr/lib/libboost_date_time.so.1.42.0 /usr/lib/libboost_math_tr1l.a /usr/lib/libboost_signals-mt.a

/usr/lib/libboost_filesystem.a /usr/lib/libboost_math_tr1l-mt.a /usr/lib/libboost_signals-mt.so

/usr/lib/libboost_filesystem-mt.a /usr/lib/libboost_math_tr1l-mt.so /usr/lib/libboost_signals.so

/usr/lib/libboost_filesystem-mt.so /usr/lib/libboost_math_tr1l.so /usr/lib/libboost_signals.so.1.42.0

/usr/lib/libboost_filesystem.so /usr/lib/libboost_math_tr1l.so.1.42.0 /usr/lib/libboost_system.a

/usr/lib/libboost_filesystem.so.1.42.0 /usr/lib/libboost_math_tr1-mt.a /usr/lib/libboost_system-mt.a

/usr/lib/libboost_graph.a /usr/lib/libboost_math_tr1-mt.so /usr/lib/libboost_system-mt.so

/usr/lib/libboost_graph-mt.a /usr/lib/libboost_math_tr1.so /usr/lib/libboost_system.so

/usr/lib/libboost_graph-mt.so /usr/lib/libboost_math_tr1.so.1.42.0 /usr/lib/libboost_system.so.1.42.0

/usr/lib/libboost_graph.so /usr/lib/libboost_prg_exec_monitor.a /usr/lib/libboost_test_exec_monitor.a

/usr/lib/libboost_graph.so.1.42.0 /usr/lib/libboost_prg_exec_monitor-mt.a /usr/lib/libboost_test_exec_monitor-mt.a
复制代码头文件在/usr/include/boost下gnuser@ubuntu:~$ ls /usr/include/boost/

accumulators date_time.hpp io_fwd.hpp pointer_cast.hpp spirit

algorithm detail iostreams pointer_to_other.hpp spirit.hpp

aligned_storage.hpp dynamic_bitset is_placeholder.hpp pool statechart

any.hpp dynamic_bitset_fwd.hpp iterator preprocessor static_assert.hpp

archive dynamic_bitset.hpp iterator_adaptors.hpp preprocessor.hpp strong_typedef.hpp

array.hpp enable_shared_from_this.hpp iterator.hpp program_options swap.hpp

asio exception lambda program_options.hpp system
复制代码boost库命名:
比如libboost_regex-vc71-mt-d-1_34.lib,

lib: 库前缀,除了windows平台,都是这个前缀
boost_regex: boost的regex库
-mt 多线程支持
-d debug版本

6. 如何编译boost linux

linux平台下要编译安装除gcc和gcc-c++之外,还需要两个开发库:bzip2-devel 和python-devel,因此在安装前应该先保证这两个库已经安装:
#yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y
然后是去官网下载源码包,按照如下步骤:
#tar xvzf boost_1_50_0.tar.gz
进入boost_1_50_0目录:
#cd boost_1_50_0
然后是编译安装,boost源码包中有配置脚本,直接用就可以:
#sh ./bootstrap.sh
Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2
Detecting Python version... 2.6
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html
接下来就是编译,重点关注是否编译成功:
#./b2

7. 如何在ubuntu下配置boost

这里有两种安装方法:

=============
第一种:

也是最简单的:进入linux系统后,输入
# apt-cache search boost
你将看到很多文件信息,你会看到其中一个文件叫 libboost-dev, 直接安装此文件即可:
# apt-get install libboost-dev
这样就安装成功了。这个速度很快,是因为直接拷贝了lib文件到系统。
可以使用本文最后代码测试安装成功与否。

==============
第二种:
这个速度比较慢,因为需要自己编译出lib库。
首先下载boost库从www.boost.org这个网站下载linux的boost库,有2种格式,1) .bz2 2) .gz
我下的是gz结尾的。放到linux的文件系统里,这里假设为/usr/local/boost_1_52_0.tar.gz

第一步:解压压缩包,命令如下,(#号仅为起始标记作用,敲命令时忽略):
# cd /usr/local/
# tar -zxvf boost_1_52_0.tar.gz

第二步:解压后得到文件夹boost_1_52_0,运行如下命令:
# cd boost_1_52_0/
# ./bootstrap.sh //这个命令类似于配好环境

第三步:运行二步命令后得到一个文件,名字是bjam,运行这个文件:
# ./bjam //这里需要十几分钟,完成后就代表安装成功了。

第四步:检验安装成功否:在linux下任意目录下创建test.cpp

#include
#include
int main()
{
int a = boost::lexical_cast("123456");
std::cout << a < return 0;
}

这是一个字符串转化为整数的简单程序

运行命令:
# g++ test.cpp -o test
# ./test

将得到输出结果为:123456
代表boost安装成功,就可以尽情使用boost的美妙了!!!

8. linux下安装boost库时,boost版本跟gcc版本有关系吗

这个当然是和 GCC 版本有关啦

考虑一些新特性的支持,选较新版本的 GCC

9. 如何在linux上使用boost:thread-C/C++

  • 首先需要安装boost,步骤如下:

下载到boost_1_49_0.tar.bz2 (当然,其他压缩格式也可以)后,可以把它放在用户目录下,即:~/

解压缩:tar -jxvf boost_1_49_0.tar.bz2

这样,出现文件夹:~/boost_1_49_0

然后进入:$ cd boost_1_49_0

你会发现有一个sh命令:bootstrap.sh

运行它:$ ./bootstrap.sh (boost自己的get start文档中说设置参数 --prefix=dir 其中dir为你想指定的安装文件夹,我建议就不用加这个参数,它会默认安装到/usr/local)

结束后出现一个可执行文件: ~/boost_1_49_0/b2

运行这个文件: $ sudo ./b2 install (Ubuntu用户千万别忘了加sudo,不然安装后将无法完全使用)

编译安装时间比较长,根据不同机器的情况20~40分钟。结束后即安装完毕。


  • boost::thread的使用

#include<boost/thread.hpp>
#include<iostream>

voidtask1(){
//dostuff
std::cout<<"Thisistask1!"<<std::endl;
}

voidtask2(){
//dostuff
std::cout<<"Thisistask2!"<<std::endl;
}

intmain(intargc,char**argv){
usingnamespaceboost;
threadthread_1=thread(task1);
threadthread_2=thread(task2);

//dootherstuff
thread_2.join();
thread_1.join();
return0;
}

编译时的命令为:
$ g++ -I./inlcude -L./lib example.cpp -lboost_thread -o example
编译之后会出现一个 example 的可执行文件,可以运行:./example , 结果显示:
This is task2!
This is task1!

可能你在运行时会出现这样的错误:error while loading shared libraries: libboost_thread.so.1.49.0: cannot open shared object file: No such file or directory

这是因为要用到的库不在默认的环境变量里,可以使用下面的命令添加:
$ sudo ldconfig /usr/local/lib

添加后,再执行./example,这样你就完成了你的第一个boost::thread程序。

10. linux CentOS7系统如何升级boost库

直接重新下载安装即可
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

热点内容
安卓手机用什么软件传软件到苹果 发布:2024-10-09 09:11:02 浏览:367
苹果安卓怎么传抖音 发布:2024-10-09 09:10:18 浏览:822
连接电视路由器如何设置密码 发布:2024-10-09 09:10:16 浏览:781
c语言取模与取余 发布:2024-10-09 08:52:51 浏览:267
安卓怎么像苹果一样滑动返回 发布:2024-10-09 08:20:46 浏览:758
gp数据库行 发布:2024-10-09 08:10:37 浏览:417
会计公需课登录密码是什么 发布:2024-10-09 08:08:20 浏览:800
wps怎么怎么加密码忘了怎么办 发布:2024-10-09 07:54:30 浏览:992
埋堆堆怎样更改缓存路径 发布:2024-10-09 07:48:12 浏览:550
壹号本1s加存储 发布:2024-10-09 07:43:51 浏览:546