c++ 库 boost安装
http://blog.chinaunix.net/uid-12226757-id-3427282.html
ubuntu
apt-get install libboost-dev
全部:
apt-get install libboost-all-dev
看有些资料写的:
apt-get install libboost-dev libboost-dbg libboost-doc bcp libboost-*
如果提示权限不够,就加上sudo或者切换到拥有足够权限的账号进行安装!
linux自身就带有STL了,是 SGI版本的,可以直接使用,不用安装。
自己编译安装:
首先要编译生成boost安装工具bjam
进入boost目录执行:
./bootstrap.sh
输出:
root@iZ23onhpqvwZ:~/download/boost_1_57/boost_1_57_0# ./bootstrap.sh
Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86/b2
Detecting Python version... 2.7
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
生成bjam,上述命令可以带有各种选项,具体可参考帮助文档: ./bootstrap.sh --help。其中--prefix参数,可以指定安装路径,如果不带--prefix参数的话(推荐),默认路径是 /usr/local/include 和 /usr/local/lib,分别存放头文件和各种库。执行完成后,会生成bjam,已经存在的脚本将会被自动备份。注意,boost 1.49会在当前目录下,生成两个文件bjam和b2,这两个是一样的,所以接下来的步骤,可以用这两个中的任意一个来执行。
using mpi ; #如果需要MPI功能,需要在 /tools/build/v2/user-config.jam 文件的末尾添加 |
接下来就是利用生成的bjam脚本编译源代码了
./b2 -a -sHAVE_ICU=1 #-a参数,代表重新编译,-sHAVE_ICU=1代表支持Unicode/ICU |
注意,这里是全部编译。当然也可以选择只编译一部分,选项 --with-<library> 只编译指定的库,如输入--with-regex就只编译regex库了。boost1.49 的完全编译,在笔者Intel® Core™2 Duo CPU T5750 @ 2.00GHz × 2 ,2G DDR2内存的老机子上,使用上述选项,半个小时就差不多了。这个时间是可以承受的。全部编译安装,心理上感觉也舒服些。^_^
我的步骤:
./b2 --prefix=/usr
一个漫长的过程。
编译完成后,进行安装,也就是将头文件和生成的库,放到指定的路径(--prefix)下
./b2 install |
测试:
#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=;int n=;
cout<<boost::bind(fun,_1,_2)(m,n)<<endl;
return ;
}
boost_1_51_0.zip 下载并解压到C盘根文件夹
二、编译boost
1、生成生命行程序
执行bootstrap.bat
2、编译
执行b2.exe,完成后显示:(时间非常之久,半个多小时)
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
C:/boost_1_51_0
The following directory should be added to linker library paths:
C:\boost_1_51_0\stage\lib (这是生成的一些列lib文件)
三、使用boost
1、创建一个win32 console
2、引用bootst
C/C++ -> Additional Include Directories: C:\boost_1_51_0
Linker-> Additional Library Directories: C:\boost_1_51_0\stage\lib
Linker->Input->Additional Dependencies :libboost_signals-vc110-mt-gd-1_51.lib;libboost_regex-vc110-mt-gd-1_51.lib;
测试code:
#include "stdafx.h"
#include <boost/regex.hpp>
#include <boost/signals.hpp>
#include <boost/lambda/lambda.hpp> #include <iostream>
#include <cassert> struct print_sum {
void operator()(int x, int y) const { std::cout << x+y << std::endl; }
}; struct print_product { void operator()(int x, int y) const { std::cout << x*y << std::endl; } }; int _tmain(int argc, _TCHAR* argv[])
{
boost::signal2<void, int, int, boost::last_value<void>, std::string> sig;
sig.connect(print_sum());
sig.connect(print_product());
sig(, );
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );
while (std::cin)
{
std::getline(std::cin, line);
boost::smatch matches;
if (boost::regex_match(line, matches, pat))
std::cout << matches[] << std::endl;
}
return ;
}
一个简单的测试:(没有特别添加库)
#include<iostream>
#include<boost/thread/thread.hpp> void hello()
{
std::cout << "Hell world,I am a thread!" << std::endl;
}
int main()
{
boost::thread test_thread(&hello);
test_thread.join(); }
参考:
http://www.cnblogs.com/chuncn/archive/2012/09/10/2679026.html
c++ 库 boost安装的更多相关文章
- dev c++ Boost库的安装
dev c++ 的boost库的安装步骤 然后点击“check for updates”按钮 最后点击“Download selected”按钮,下载完成后安装.... 给dev添加boost库文件, ...
- Dev-C++安装第三方库boost
Dev-C++安装第三方库boost 转 https://www.jianshu.com/p/111571e4d6f5?utm_source=oschina-app 之前鉴于codeblocks界面 ...
- 1.boost库的安装
一.前言 好好研究下大名鼎鼎的Boost库. 二.Boost安装 2.1Boost官网下载Boost最新版Version 1.55.0 2.2将下载压缩包解压到本地 解压后可看到目录下有个bootst ...
- 机器学习库shark安装
经过两天的折腾,一个对c++和机器学习库的安装都一知半解的人终于在反复安装中,成功的将shark库安装好了,小小纪念一下,多亏了卡门的热心帮忙. shark的安装主要分为以下几个部分: (1)下载 s ...
- C++三大库boost、loki、stlport
转: STL是一个标准,各商家根据这个标准开发了各自的STL版本.而在这形形色色的STL版本中,SGI STL无疑是最引人瞩目的一个.这当然是因为这个STL产品系出名门,其设计和编写者名单中,Alex ...
- Linux平台的boost安装全解
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...
- 【Todo】Boost安装与学习
现在这里找下载包 http://sourceforge.net/projects/boost 我找的是 1_62_0 下面是从公司wiki上找到的一个说明. boost & thrift安装步 ...
- Boost 安装详解
一 Linux(redhat)篇 1.1 获取boost库 解压tar -zxvf boost_1.48.0.tar.gz 进入解压目录cd boost_1_48_0 1.2 编译安装 使用下面的命令 ...
- 【视频开发】【计算机视觉】doppia编译之二:boost安装
编译安装boost库的方法大部分都是来自http://www.linuxidc.com/Linux/2013-07/87573.htm这篇文章,这里我用自己的语言重新组织,稍作修改和补充,最主要是方便 ...
随机推荐
- IDEA2017 导入 SVN上的 Myeclipse或Eclipse 项目
从SVN上检出项目,不用打开. 关闭IDEA后选择 import project,导入后按F4 (改成eclipse按键模式后 按ctrl alt shift F4)进入 project struct ...
- 企业Shell面试题5:解决DOS攻击生产案例
企业Shell面试题5:解决DOS攻击生产案例 写一个Shell脚本解决DOS攻击生产案例. 请根据web日志或者或者网络连接数,监控当某个IP并发连接数或者短时内PV达到100(读者根据实际情况设定 ...
- NIPS(Conference and Workshop on Neural Information Processing Systems)
论文提交时间:5月下旬 会议时间:12月上旬 NIPS2017: 网址:https://nips.cc/
- 第一百五十八节,封装库--JavaScript,ajax说明
封装库--JavaScript,ajax说明 封装库ajax()方法,ajax通讯方法,跨页面向动态页面发送或获取数据 /** ajax()方法,ajax通讯方法,跨页面向动态页面发送或获取数据 * ...
- 【机器学习】WIFI室内定位
WIFI室内定位-指纹法 在A1区域内每个点上采集四个WiFi的信号数据(信号强度),五点.九点.十六点采样. 5*5=25区域*16数据=400样本,用来训练 样本数 R B G1 G2 1 2 ...
- boost数据结构tuple
boost数据结构tuple tuple(元组)定义了一个有固定数目元素的容器,其中每个元素类型可以不相同,这与其它容器有着本质的区别!vector和array虽然可以容纳很多元素,但是元素的类型必须 ...
- C#基础语言知识--编译和执行过程
http://blog.csdn.net/stive_sourcexin/article/details/51329697
- Django admin 的 9 个技巧
Tip 1:Django admin 后台不限于用 Django 开发的网站 虽然 Django admin 管理界面可以非常友好的用在 Django 项目的其它部分,它同样可以很容易用于其它像传统的 ...
- Docker入门与应用系列(五)Dockerfile
Dockerfile是为快速构建docker image而设计的,当你使用dockerbuild 命令的时候,docker 会读取当前目录下的命名为Dockerfile(首字母大写)的纯文本文件并执行 ...
- 关于在ubuntu平台下使用apt-get命令下载速度太慢的问题解决
1. 进入设置,从哪进都一样找到就行. 2.选择软件与更新(Software and updates,英语估计是这个把) 点击下载自:这个下拉框,选中其它站点,选择镜像 选择阿里的或者搜狐的镜像,然后 ...