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这篇文章,这里我用自己的语言重新组织,稍作修改和补充,最主要是方便 ...
随机推荐
- mysql information_schema 数据库简介:
.CHARACTER_SETS 表 CREATE TEMPORARY TABLE `CHARACTER_SETS` ( `CHARACTER_SET_NAME` varchar() NOT NULL ...
- (转)Python爬虫学习笔记(2):Python正则表达式指南
以下内容转自CNBLOG:http://www.cnblogs.com/huxi/archive/2010/07/04/1771073.html 1. 正则表达式基础 1.1. 简单介绍 正则表达式并 ...
- CentOS安装python setuptools and pip
安装setup-tools wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg --n ...
- JS动态增加删除UL节点LI及相关内容示例
<ul id="ul"> <li id=1>11111111111111111<a href="javascript:del(1);&quo ...
- python通过日志分析加入黑名单
监控nginx日志,若有人攻击,则加入黑名单,操作步骤如下:1.读取日志文件2.分隔文件,取出ip3.将取出的ip放入list,然后判读ip的次数4.若超过设定的次数,则加入黑名单 日志信息如下: 1 ...
- 第二百零八节,jQuery EasyUI,SplitButton(分割按钮菜单)组件
jQuery EasyUI,SplitButton(分割按钮)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 SplitButton(分割按钮)组件的使用 ...
- OpenWrt 安装usb支持
(一)下载软件 1)komd-usb-ohci kmod-usb2 kmod-usb-storage kmod-usb-core 这些是USB驱动包 2) kmod-nls-base kmod-nls ...
- 蓝桥杯 第三届C/C++预赛真题(9) 夺冠概率(手工计算概率)
足球比赛具有一定程度的偶然性,弱队也有战胜强队的可能. 假设有甲.乙.丙.丁四个球队.根据他们过去比赛的成绩,得出每个队与另一个队对阵时取胜的概率表: 甲 乙 丙 丁 甲 - 0.1 0.3 0.5乙 ...
- VC++ 在Watch窗口显示GetLastError值以及详细信息
You can display the value GetLastError() will return by putting "@err" in your watch windo ...
- nodejs 循环中操作需要同步执行解决方案
最近用nodejs做了个针对某网站的小爬虫.干坏事得低调对吧,不能同时开太多的网络访问,结果各种回调/循环虐的心力交瘁. 经过了n次的百度\哥哥后终于拼出了自己要的功能.不敢独享分享出来以供大家参考. ...