现在这里找下载包

http://sourceforge.net/projects/boost

我找的是 1_62_0

下面是从公司wiki上找到的一个说明。

boost & thrift安装步骤
1. boost安装
cd /usr/local
tar zxvf boost_1_49_0.tar.gz
./bootstrap.sh --prefix=/usr/local/boost_1_49_0
./b2 install 2. thrift安装
tar zxvf thrift-0.8.0.tar.gz
cd thrift-0.8.0
./configure --with-boost=/usr/local/boost_1_49_0 --prefix=/home/work/local/thrift-0.8.0
make
make install make如有下面报错:
…: tr1/functional: No such file or directory

make[4]: Leaving directory `/home/work/thrift-0.8.0/lib/cpp'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/work/thrift-0.8.0/lib/cpp'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/work/thrift-0.8.0/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/work/thrift-0.8.0'
make: *** [all] Error 2 则修改如下3个文件:
vi lib/cpp/src/concurrency/ThreadManager.h
24 #include <boost/tr1/tr1/functional> vi lib/cpp/src/async/TAsyncChannel.h
23 #include <boost/tr1/tr1/functional> vi lib/cpp/src/async/TAsyncChannel.cpp
21 #include <boost/tr1/tr1/functional>

开始,我直接用

./bootstrap.sh
./b2
./b2 install

结果报了很多错,基本都是fail或者skip.

然后按照上面的提示,指定了一下目录:

./bootstrap.sh --prefix=/home/work/data/installed/boost
./b2 install

还是有一些skip的提示:

...failed updating 50 targets...
...skipped 35 targets...
...updated 13364 targets...

但是已经比之前好多了,已经成功更新了10000+targets.

在目录 /home/work/data/code/boost_demo 里面,写一段demo代码 boost_demo.cpp 如下:

#include  <boost/lexical_cast.hpp>
#include <iostream> int main() {
using boost::lexical_cast;
int a = lexical_cast<int> ("123");
double b = lexical_cast<double> ("123.12");
std::cout << a << std::endl;
std::cout << b << std::endl;
return 0;
}

编译命令如下:

g++ -Wall -I/home/work/data/installed/boost/include/ -o test_boost boost_demo.cpp

但是报错找不到头文件:

boost_demo.cpp:1:37: boost/lexical_cast.hpp : No such file or directory

分析了一下,是因为boost没有装在标准目录,所以需要用""代替<>,代码改成:

#include  "boost/lexical_cast.hpp"
#include <iostream> int main() {
using boost::lexical_cast;
int a = lexical_cast<int> ("123");
double b = lexical_cast<double> ("123.12");
std::cout << a << std::endl;
std::cout << b << std::endl;
return 0;
}

编译后运行:

g++ -Wall -I/home/work/data/installed/boost/include/ -o test_boost boost_demo.cpp

./test_boost

123
123.12

注意,boost大多数库一般都不需要添加-L或者-l参数,用-I指定头文件路径即可。要根据不同的库的情况来处理。

然后在我自己的Mac机器上,运行 brew search boost 查看,发现boost貌似已经安装,写程序实验了一下(仍然用上面的程序,""可以写成<>)。

编译,运行:

g++ -o boost_demo boost_demo.cpp

./boost_demo

123
123.12

以上。后续,再对boost做更多学习和实验。

【Todo】Boost安装与学习的更多相关文章

  1. 20165226 预备作业3 Linux安装及学习

    20165226 预备作业3 Linux安装及学习 Linux安装 一.下载安装VirtualBox 1.首先在官网下载,点开基于VirtualBox虚拟机安装Ubuntu图文教程 找到版本进行下载安 ...

  2. 20165230 预备作业3 Linux安装及学习

    20165230 预备作业3 Linux安装及学习 安装Linux操作系统 通过学习实践基于VirtualBox虚拟机安装Ubuntu图文教程,开始了虚拟机的安装,根据教程按着步骤一步一步的完成. 遇 ...

  3. Torch的安装和学习

    Long long ago, 就已经安装好Torch,这里再记录一下.Torch是Facebook开发的用于AI的科学计算框架,可广泛运用于机器学习的很多算法.相比Caffe,其接口运用更加方便,使用 ...

  4. 【freeradius2.x】 安装和学习

    虚拟机中centos 安装和学习 radius2 版本是2.2.x 的使用等知识 安装 为了测试方面,yum安装 yum -y install freeradius* 配置文件的位置是 /etc/ra ...

  5. 20165237 预备作业3 Linux安装及学习

    Linux安装及学习 安装 对操作系统略知一二的我,按照老师发的基于VirtualBox虚拟机安装Ubuntu图文教程慢慢一步步往下做,虽然中间有些小困难,但最终都得以解决,安装成功. 遇到的小困难: ...

  6. 20165325 预备作业3 Linux安装及学习

    Linux安装及学习 一.VirtualBox和Ubuntu安装 问题一:虚拟机中Ubuntu的版本 在设置虚拟机的操作系统的版本时,我发现我的电脑只能设置32-bit的Ubuntu版本.教程上选用了 ...

  7. 20165206 预备作业3 Linux安装及学习

    Linux的安装与学习 - 在自己笔记本上安装Linux操作系统 在安装虚拟机的过程中遇到了不少问题,但也都进行了尝试并得到了解决.首先是在安装VirtulBox的安装上,按照老师给的链接下载安装,不 ...

  8. redis 安装配置学习笔记

    redis 安装配置学习笔记 //wget http://download.redis.io/releases/redis-2.8.17.tar.gz 下载最新版本 wget http://downl ...

  9. 20165317 Linux安装及学习

    Linux安装及学习 一.Linux的安装 我通过virtualbox和ubuntu官网下载了virtualbox5.2.6和ubuntu17.04版本. 在操作过程中,我基本是按照老师的步骤进行的, ...

随机推荐

  1. C语言 ,两个字符串参数,判断是否包含另一个字符串,返回所在位置

    char * cyp(char *s1,char *s2) { char *p = NULL; char *q = NULL; char *q1 = NULL; while(*s1!='\0') { ...

  2. MapReduce案例二:好友推荐

    1.需求 推荐好友的好友 图1: 2.解决思路 3.代码 3.1MyFoF类代码 说明: 该类定义了所加载的配置,以及执行的map,reduce程序所需要加载运行的类 package com.hado ...

  3. LeetCode212. Word Search II

    https://leetcode.com/problems/word-search-ii/description/ Given a 2D board and a list of words from ...

  4. List转换为DataTable List<Entity>

    /// <summary> /// 将List转换成DataTable /// </summary> /// <typeparam name="T"& ...

  5. f'lask源码

    上下文本质 ? 1 2 3 4 5 6 7 8 - 当请求过来后,将请求相关数据添加到 Local()类中     {         线程或协程唯一标识:{"stack":[re ...

  6. opencv c++实用操作

    像素遍历 对单通道图像的遍历处理 For( int i =0 ; i < grayim.rows; i++) For(int j = 0; j<grayim.cols; j++) Gray ...

  7. python import模块的搜索路径

    当在py代码中import所依赖的模块时, python是从哪里找到这些模块呢,即模块的搜索路径是啥? 默认情况下,Python解释器会搜索当前目录.所有已安装的内置模块和第三方模块,搜索路径存放在s ...

  8. SecureCrt的操持连接办法

    保持连接: options -> global options -> General -> Default Session,点击Edit default settings按钮,在Te ...

  9. vue模糊搜索&select取值

    之前vue1.0的过滤器真的很好使,但是作者为了不让搬运工变得太菜.硬是砍去了过滤器,为此,我还哭了好一阵,终于,一点一点的弄明白了过滤器是怎么回事后,也学明白了vue里的属性监听器computed以 ...

  10. jquery.bootpag分页控件

    <script src="//code.jquery.com/jquery-2.1.3.min.js"></script> <script src=& ...