Linux系统下Boost库编译与安装
2017-08-30 14:53
357 查看
Linux系统下Boost库编译与安装
类库下载
可以通过以下链接方式获得官网下载链接 : http://www.boost.org
github源代码 :https://github.com/boostorg/boost
由于Boost大量使用了C++的高级特性,因此不同版本的Boost库需要的编译器也不同,组件对编译器支持也不同,建议使用前更新编译器版本。本文使用的编译器为 gcc version 5.3.1、boost1.64
快捷安装
下载解压后,在linux中进入boost 文件夹中(安装前为文件夹添加权限,防止权限问题导致失败)依次运行文件夹下可执行文件:
./bootstrap.sh // 编译前的配置工作,脚本内包含配置信息 ./b2 install // 编译安装Boost
上述情况将直接编译安装release版本的库文件,并把头文件安装到/usr/local/include中,库文件安装到/usr/local/lib下。
完全安装
默认快捷安装时,使用release模式,需要安装全部boost版本时可以通过使用buildtype选项指定编译类型,如指定完整编译类型./boostrap.sh ./b2 --buildtype=complete install
该方式将进行完整编译,安装所有调试版、发行版的静态、动态库。
部分安装
很多情况下,我们只需要boost 库的部分内容,完整编译费时费力,因此可以通过编译选项自行选择需要编译安装的库,依然是./b2执行文件使用./b2 --show-libraries // 显示需要编译才能使用的库 // 运行结果: The following libraries require building: - atomic - chrono - container - context - coroutine - coroutine2 - date_time - exception - fiber - filesystem - graph - graph_parallel - iostreams - locale - log - math - metaparse - mpi - program_options - python - random - regex - serialization - signals - system - test - thread - timer - type_erasure - wave // 仅编译单个库时,可以通过with/without添加删除 ./b2 --with-thread --buildtype=complete install // 运行结果: The Boost C++ Libraries 8da6 were successfully built! The following directory should be added to compiler include paths: /Users/lwq/Desktop/Boost/boost_1_64_0 The following directory should be added to linker library paths: /Users/lwq/Desktop/Boost/boost_1_64_0/stage/lib
可以看到,编译结果被放到了当前目录下,通过命令:
./bootstrap --help ./b2 --help
或通过Boost文档,可以查询编译主要选项,指定安装的路径、版本。
本人的安装选项为
sudo ./b2 link=static install #编译安装所有静态库
环境验证
通过简单的Boost应用程序验证开发环境。在头文件<boost/version.hpp> 中定义了两个宏:程序库版本号
#include <iostream> // Boost测试程序 #include <boost/version.hpp> #include <boost/config.hpp> int main() { std::cout << "版本号(数字):" << BOOST_VERSION << std::endl; std::cout << "版本号(字符串):" << BOOST_LIB_VERSION << std::endl; std::cout << "操作系统:" << BOOST_PLATFORM << std::endl; std::cout << "编译器:" << BOOST_COMPILER << std::endl; std::cout << "标准库:" << BOOST_STDLIB << std::endl; return 0; }
通过直接输出相关信息,检查能否正确使用Boost文件即可。
相关文章推荐
- Linux 文件系统 用户安装程序 编译程序
- linux系统管理--软件包的编译安装
- Linux系统常用的软件管理工具rpm、yum及软件源码编译安装 推荐
- Ubuntu 12.04系统天嵌Linux交叉编译开发工具的安装
- boost库linux编译安装
- 在WdOS系统下源代码编译安装LNMP环境(Linux+Ngnix+Mysql+Php)
- boost库linux编译安装
- linux 编译系统的简单介绍与内核编译与安装
- linux系统下查看nginx、apache、mysql和php已经安装的编译 9fb2 参数查看
- linux RHEL x86_64bit 系统安装 32bit兼容库 和 编译32bit程序
- Linux系统之工具篇(一)DRBD Centos6.5(64bit)编译安装,双主模式
- Linux系统下编译安装飞鸽传书g2ipmsg
- Linux 环境下部署Hadoop 2.x,建议尝试64位系统下进行本地编译的安装方式
- 在Linux,Windows和Mac三大系统下编译Boost库
- 如何用新安装的JDK替换掉Linux系统自带的gij编译工具
- centos将自编译安装的apache添加为linux系统服务
- wdOS系统下源码编译安装LAMP环境(linux+apache+php+mysql)
- linux系统替换新内核(编译安装替换与打包替换)
- Ubuntu 12.04系统天嵌Linux交叉编译开发工具的安装
- Linux系统 - 源码编译安装Nginx