QT使用boost serialization库进行序列化操作
boost serialization库在QT中的使用
1.获取boost库,本次使用boost_1_81_0版本,下载链接https://www.boost.org/users/download/
2.解压boost压缩包,双击执行bootstrap.bat 会生产编译工具b2.exe;
3.使用b2.exe进行编译serialization,编译命令如下
b2 --toolset=gcc --prefix=C:\Users\Admin\Downloads\boost_1_81_0\libb link=static --with-serialization release install
注意:在使用gcc时,需要将QT编译时使用的编译链gcc加入系统环境变量 ,编译命令解释请在结尾所附连接中查询,编译时尽量 避免全编,选择自己需要的库进行编译即可。
4.将编译完成的.a静态库和对应头文件拷贝到QT工程目录下![在这里插入图片描述](https://img-blog.csdnimg.cn/d2288218f465472eb75f5af65e843758.png)
在项目文件pro中加入lib路径、头文件路径、对应的lib库
INCLUDEPATH += $$PWD/boost
CONFIG(debug, debug|release){
#boost library
win32{
LIBS += -L$$PWD/lib
-llibboost_serialization-mgw5-mt-x32-1_81
-llibboost_wserialization-mgw5-mt-x32-1_81
}
}else{
#boost library
win32{
LIBS += -L$$PWD/lib
-llibboost_serialization-mgw5-mt-x32-1_81
-llibboost_wserialization-mgw5-mt-x32-1_81
}
}
在需要使用到boost库的头文件中加入boost相关头文件
参考连接:
https://www.bbsmax.com/A/gVdn9eoa5W/
https://blog.csdn.net/yshuise/article/details/120616423
https://blog.csdn.net/xs1102/article/details/103156342