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这篇文章,这里我用自己的语言重新组织,稍作修改和补充,最主要是方便 ...
随机推荐
- 信号signal编号及意义及一般处理
SIGQUIT:停止 SIGILL:illegal instruction SIGABRT:Abort SIGFPE:Float point exception SIGPIPE:Broken pipe ...
- PHP上传类 图片上传 upload class实现image crop resize 缩略图
manage uploaded files, and manipulate images in many ways through an HTML form, a Flash uploader, XM ...
- Docker 和一个正常的虚拟机有何区别?
问: 我多次重读Docker.io文档,希望搞明白Docker.io和一个完全的虚拟机的区别.Docker是如何做到提供一个完整的文件系统,独立的网络环境等等这些功能,同时还没有如此庞大? 为什么部署 ...
- <!>连结格式
<base href=位址>(预设好连结路径) <a href=位址></a>外部连结 <a href=位址 target=’_blank’></ ...
- 【vijos】1763 Wormhole(贪心)
https://vijos.org/p/1764 首先第一个虫洞一定是建在1号点. 证明如下: 假设一个虫洞在a,一个在b,a<b,那么走到k点的最短距离为 min{|x1-xk|, |x1-x ...
- Openstack(Kilo)安装系列之nova(七)
控制节点 Before you install and configure the Compute service, you must create a database, service crede ...
- jvm之 国际酒店 一次报表 load数据死循环导致的FULLGC
从目前这几天的运行情况看,每天晚上0点到3点,应该是你们那边有大数据任务处理,在这个时间段,SOA会频繁报ZK断开重联的告警,见下图. 类似的问题,在CRM系统上也有出现过,我们dump内存,分析 ...
- 《基础知识》hashCode与equals的区别与联系
一.equals方法的作用 1.默认情况(没有覆盖equals方法)下equals方法都是调用Object类的equals方法,而Object的equals方法主要用于判断对象的内存地址引用是不是同一 ...
- MVC Model验证疑难杂症
Q1:有验证但是还是能进入控制器(Controller) 排查之后发现js报错:VM109:1 Uncaught SyntaxError: Unexpected token u in JSON at ...
- ajax 传递数组类型参数后台接收不到的问题
在做排序功能的时候需要将一个数组的数据传递到后台,(当时怎么没用json,如果用json就没有那么多的事情了),数据提交采用ajax! 先看代码 js: submitbtn: function () ...