由于现在的项目有一部分能要开始用 C++, 所以现在准备开始学习流行的boost库,
准备环境:cygwin + win7
1) 先安装cygwin(如果已经安装直接跳过这一步)
2) 利用cygwin安装boost库
如果不从cygwin安装你可以下载boost库文件,然后解压开来在用cygwin的gcc编译安装:命令如下:
$ ./bootstrap.sh
结束后
$ ./bjam.exe install
装完后检验一下boost是否成功如下:
#include <stdio.h>
#include <boost/timer.hpp>
#include <iostream>
using namespace std;
using namespace boost;
int main(){
timer t;
cout << "max timspan:" << t.elapsed_max() /3600 << "h" <<endl;
std::cout << "max_teimspan:" << t.elapsed_max() /3600 << "h";
cout << "min timspan: " << t.elapsed_min() << "s" << endl;
}
然后编译一下看看能否运行成功
如果成功就证明ok了
1) 偶在配置的过程中碰到文件权限问题还有编译后的include 文件时空的打不开,解决办法是:将下载的boost文件目录直接考到cygwin下去
2) 在上面的例子中如果不加std会报错cout没哟定义,这个是典型的c++的命名空间问题,可以加上你要的命名空降或者你直接用std:cout这样的方法来解决