Linux系统下Boost库编译与安装
来源:互联网 发布:化工控制软件 编辑:程序博客网 时间:2024/06/04 19:02
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 were successfully built!The following directory should be added to compiler include paths: /Users/lwq/Desktop/Boost/boost_1_64_0The 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文件即可。
阅读全文
0 0
- Linux系统下Boost库编译与安装
- LINUX 下BOOST完整编译与安装
- LINUX 环境下BOOST 库安装编译
- linux下编译安装boost库
- Linux下boost编译安装
- Linux下编译安装BOOST
- Linux下编译安装boost
- Linux下Boost编译安装
- boost库linux编译安装
- boost库linux编译安装
- linux 安装、编译boost库
- boost库编译与安装
- 在Linux与Winodws下编译boost
- Linux系统下编译Boost库,并在Qt Creator中使用Boost库
- Linux系统下编译Boost库,并在Qt Creator中使用Boost库 .
- linux下编译boost
- linux下编译BOOST
- linux下编译boost
- 如何应对别人说你的设计还可以更完美
- 匿名内部类的方法参数一定要设置final
- curl模拟http发送get或post请求
- 【CodeForces 158E】Phone Talks(DP)
- 【Unity与23种设计模式】责任链模式(Chain of Responsibility)
- Linux系统下Boost库编译与安装
- FileUtils的方法
- 替换空格
- HDU 1181 变形课
- 20.Redis Cluster
- Codeforces Round #430 (Div. 2) A. Kirill And The Game
- 交互设计新手路要怎么走
- action和action之间传数据
- SQOOP from Oracle Connection reset error