📦 Boost
参考
setup
linux
-
通过 apt
Bash 1
sudo apt-get install libboost-all-dev
-
下载
wget
/ 解压tar -zxvf
/ 提权chmod +x
-
配置安装选项
./bootstrap.sh --prefix=/.../boost-x.y.z
-
安装
./b2 -j$(nproc) --prefix=/.../boost-x.y.z install
-
编写测试代码
5. 编译C++ 1 2 3 4 5 6 7 8 9 10 11 12 13
#include <boost/version.hpp> #include <boost/config.hpp> #include <iostream> using namespace std; int main(){ cout << BOOST_VERSION << endl; // Boost 版本号 cout << BOOST_LIB_VERSION << endl; // Boost 版本号 cout << BOOST_PLATFORM << endl; // 操作系统 cout << BOOST_COMPILER << endl; // 编译器 cout << BOOST_STDLIB << endl; // 标准库 return 0; }
Bash 1
g++ test.cpp -I/.../boost-x.y.z/include -L/.../boost-x.y.z/lib
windows
-
下载 Boost
-
解压
-
进入解压后的目录,执行
.\bootstrap.bat gcc
- 编译前的配置工作
-
执行
.\b2.exe install
- 编译安装
-
测试
C++ 1 2 3 4 5 6 7 8 9 10 11 12 13
#include <boost/version.hpp>//包含 Boost 头文件 #include <boost/config.hpp> //包含 Boost 头文件 #include <iostream> using namespace std; int main(){ cout << BOOST_VERSION << endl; // Boost 版本号 cout << BOOST_LIB_VERSION << endl; // Boost 版本号 cout << BOOST_PLATFORM << endl; // 操作系统 cout << BOOST_COMPILER << endl; // 编译器 cout << BOOST_STDLIB << endl; // 标准库 return 0; }
- 编译
Bash 1
g++ -o test test.cpp -I"C:\Boost\include\boost-1_84" -L"C:\Boost\lib"
- 如果使用网络库,还需要
-lws2_32
- 编译
dev
Boost.PropertyTree
属性树,数据结构为🌲,键值对形式存在,可以嵌套,适用于配置文件,如 JSON、XML 等
C++ | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|