Centos编译boost
2016-01-11 11:53
501 查看
Centos编译boost
http://blog.sina.com.cn/s/blog_6f2caee40100uhj6.html <div id="sina_keyword_ad_area2" "="">
1.下载最新的boost http://www.boost.org/
2.解压文件
tar -xzvf boost_1_45_0.tar.gz
3.编译bjam
进入boost_1_45_0目录中,运行./bootstrap.sh,完成后会得到一个bjam
4.编译boost
./bjam --with-date_time --with-system --with-regex --with-thread --with-filesystem --with-serialization --with-iostreams --with-math --with-mpi --with-program_options --with-python --with-math
--with-signals --layout=tagged install variant=debug,release link=static --runtime-link=static threading=multi stage
5.查看boost
编译完成后,在/usr/local/include/boost就有最新的boost头文件了,在/usr/local/lib就有编译好的.a库文件了。
虽然usr/local/include和/usr/include都有目录,但GCC是先访问/usr/local/include,所以编译完成后,就可以默认使用boost了。
6.测试boost
vi testboost.cpp
#include <iostream>
#include <boost/version.hpp>
int main()
{
std::cout<<BOOST_VERSION<<std::endl;
return 0;
}
编译:g++ -o testboost testboost.cpp
//一下自定义目录
3.编译bjam
5.设置环境变量
在/etc/profile.d新建可执行文件boost.sh,添加文件内容:
vi /etc/profile.d/boost.sh
将其保存为/etc/profile.d/boost.sh,并使用chmod a+x boost.sh设置执行权限。
命令行执行:source
/etc/profile.d/boost.sh
第一个测试文件是lex.cpp:
编译:
运行:
输出:
你可以将$BOOST_ROOT改为$BOOST_INCLUDE,如果你没有设置环境变量,可以改为/opt/boost_1_33_1或者/usr/local/include/boost-1_33_1。
http://blog.sina.com.cn/s/blog_6f2caee40100uhj6.html <div id="sina_keyword_ad_area2" "="">
1.下载最新的boost http://www.boost.org/
2.解压文件
tar -xzvf boost_1_45_0.tar.gz
3.编译bjam
进入boost_1_45_0目录中,运行./bootstrap.sh,完成后会得到一个bjam
4.编译boost
./bjam --with-date_time --with-system --with-regex --with-thread --with-filesystem --with-serialization --with-iostreams --with-math --with-mpi --with-program_options --with-python --with-math
--with-signals --layout=tagged install variant=debug,release link=static --runtime-link=static threading=multi stage
5.查看boost
编译完成后,在/usr/local/include/boost就有最新的boost头文件了,在/usr/local/lib就有编译好的.a库文件了。
虽然usr/local/include和/usr/include都有目录,但GCC是先访问/usr/local/include,所以编译完成后,就可以默认使用boost了。
6.测试boost
vi testboost.cpp
#include <iostream>
#include <boost/version.hpp>
int main()
{
std::cout<<BOOST_VERSION<<std::endl;
return 0;
}
编译:g++ -o testboost testboost.cpp
//一下自定义目录
3.编译bjam
./bootstrap.sh --prefix=/home/alex/boost
4. ./bjam install
5.设置环境变量
在/etc/profile.d新建可执行文件boost.sh,添加文件内容:
vi /etc/profile.d/boost.sh
#!/bin/sh#boost settings BOOST_ROOT=/work/BOOST/boost1_60/ BOOST_INCLUDE=/work/BOOST/boost1_60/include BOOST_LIB=/work/BOOST/boost1_60/lib export BOOST_ROOT BOOST_INCLUDE BOOST_LIB
将其保存为/etc/profile.d/boost.sh,并使用chmod a+x boost.sh设置执行权限。
命令行执行:source
/etc/profile.d/boost.sh
第一个测试文件是lex.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++ lex.cpp -I$BOOST_ROOT -o lex
运行:
./lex
输出:
123 123.12
你可以将$BOOST_ROOT改为$BOOST_INCLUDE,如果你没有设置环境变量,可以改为/opt/boost_1_33_1或者/usr/local/include/boost-1_33_1。
相关文章推荐
- linux命令学习
- linux编程
- 通过ftp上传文件到linux
- linux防火墙
- linux→查看当前系统时间和修改系统当前时间
- linux锁定系统重要文件
- Linux(centos)的常用基本命令
- 在Windows基础上(硬盘)安装Linux操作系统(CentOS/RedHat)
- Linux挂载U盘
- 完美解决 Linux 下 Sublime Text 中文输入
- Linux下的多进程编程初步(转载)
- linux C下的setjmp与longjmp介绍
- Linux 下smi/mdio总线通信
- tar包在linux下 java安装
- tar包在linux下 java安装
- linux的top命令参数详解
- 每天一个Linux命令 - 【chkconfig】
- win7的目录和vbox的共享,linux中没有权限打开
- Centos 6.5系统下搭建Git服务器--失败历程
- centos7 64 rpm 安装 mysql 5.7.10