cygwin下boost编译安装
来源:互联网 发布:孤岛惊魂3低配置优化 编辑:程序博客网 时间:2024/04/29 11:05
1、下载boost_1_40_0.tar.bz2 (http://sourceforge.net/projects/boost/files/boost/)
2、解压tar --bzip2 -xf /home/Administrator/boost_1_40_0.tar.bz2
3、有些库文件不用编译就能工作:
Boost.DateTime has a binary component that is only needed if you're using its to_string/from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland.
Boost.Graph also has a binary component that is only needed if you intend to parse GraphViz files.
Boost.Test can be used in “header-only” or “separately compiled” mode, although separate compilation is recommended for serious use.
有些库文件一定要编译:
Boost.Filesystem
Boost.IOStreams
Boost.ProgramOptions
Boost.Python (see the Boost.Python build documentation before building and installing it)
Boost.Regex
Boost.Serialization
Boost.Signals
Boost.System
Boost.Thread
Boost.Wave
4、试着编写一个不需要编译库的程序:
//////////////////////////////////////////////////////
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
///////////////////////////////////////////////////////////
example.cpp c文件如上面。把他保存在/home/Administrator下面。
g++ -I boost_1_40_0 example.cpp -o example
运行 $echo 1 2 3 | ./example
5、编译库文件:
$ cd path/to/boost_1_40_0
$ ./bootstrap.sh
产生bjam文件
$ ./bjam install
安装头文件 时间很久
将会把boost头文件拷贝到/usr/local/include
6、试着编写一个需要编译库的程序:
#include <boost/regex.hpp>
#include <iostream>
#include <string>
int main()
{
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[2] << std::endl;
}
}
编译 $g++ example1.cpp -o example1 -L/home/Administrator/boost_1_40_0/stage/lib -lboost_regex
如果把-lboost_regex.a 文件拷到/lib目录下
只要 $g++ example1.cpp -o example1 -lboost_regex
7、试过OK。哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
- cygwin下boost编译安装
- 在cygwin下编译boost库
- Cygwin环境下使用Android NDK r9c编译boost 1.55
- Cygwin环境下使用Android NDK r9c编译boost 1.55
- vs2010下编译安装boost
- vs2010下编译安装boost
- Linux下boost编译安装
- Linux下编译安装BOOST
- Linux下编译安装boost
- Linux下Boost编译安装
- cygwin下编译安装gcc 4.7.2
- boost在cygwin下的安装和使用
- Windows下(不用cygwin)NDK直接编译编译boost 1.55
- VS2008下Boost库的安装编译
- Ubuntu下boost库编译安装
- LINUX 下BOOST完整编译与安装
- 【转载】ubuntu下编译安装boost库
- Redhat下 Boost库1.54编译安装
- Symbian OS 错误代码(Error Codes )(-1999~ -601)
- 限定IP访问SQL Server
- C++虚函数与虚函数表
- lpad
- FTP基础知识
- cygwin下boost编译安装
- 离职的日子
- Ant学习
- 插入DLL和挂接API——Windows核心编程学习手札之二十二
- C++常用排序法研究
- Symbian OS 错误代码(Error Codes )(-4000~ -2000)
- 使用系统表的注意use 库
- 是魔术还是骗局:英魔术师预测彩票号码全中被禁止购买彩票
- 选定B1i,环境搭建好