cygwin下boost编译安装
2009-09-11 16:13
369 查看
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。哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
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。哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
相关文章推荐
- Boost下载安装编译配置使用指南(含Windows和Linux)
- 在Windows7下采用cygwin编译安装swoole扩展
- boost 库 window7下安装编译 +visual studio 2015
- boost编译安装问题
- boost 1.39编译安装手记
- VS2010 Boost编译安装(原)
- memcache编译安装(cygwin环境)
- centos7.1编译安装 Thrift0.9.3及boost1.6
- MacOS下Boost编译安装指南
- C++ Boost在Windows和Linux下的编译安装
- VS2010 Boost编译安装
- boost 1.47 编译安装,(windows and linux )
- Boost下载安装编译配置使用指南
- 使用b2命令进行最小boost源码多线程库编译安装
- Boost下载安装编译配置使用指南(含Windows和Linux)
- ubuntu16.04编译安装mysql-boost-5.7.21并编译成php扩展测试与使用
- Windows下Cygwin环境的Hadoop安装- 在Eclipse中重新编译hadoop的jar包
- Boost下载安装编译配置使用指南(含Windows和Linux)
- ubuntu下boost编译安装
- CentOS 5.5 安装配置全攻略 (无线上网 更新源 显卡驱动 firefox3.6 flash插件 编译boost1.43.0 雅黑字体