[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
在学习linux系统C++网络开发时,boost库的安装花费了我不少时间。在此将我的经历记录下来,方便学习交流。
在学习linux开发的过程中,Centos与Ubuntu两个系统我都有使用。两个系统都有各自的软件安装器:Centos为yum,而Ubuntu为apt-get。就我个人而言,在使用感觉上,yum要稍好于apt-get。
在软件安装时,最好使用系统自带的安装器。安装器会在软件安装时自动处理好相关依赖,若自行手动安装,不仅要学会自行处理复杂的依赖,不同时期的软件依赖还有可能发生变化,极有可能安装失败。
说回boost库的安装,在Centos与Ubuntu自带的软件源中都包含boost库,直接安装即可:
Centos:
yum install boost yum install boost-devel yum install boost-doc
Ubuntu:
apt-cache search boost sudo apt-get install libboost-all-dev
C++在编译时若需要使用boost库记得使用 -lboost_system
Centos在安装完成后即可直接使用,Ubuntu在编译时会提示找不到boost库,即便我将boost手动加入了系统路径,也没有解决问题。最终只有Centos成功安装。
如果有明白解决方法的大佬欢迎留言。
<>gcc的升级
在Centos完成安装后,我试着去编译写好的C++文件,发现auto类型无法识别。查看自带的gcc版本为4.8,太过老旧,没有完全支持C++11标准。
我使用的是Centos7系统,Centos7为了保证系统稳定,软件都采用了较低版本,而且自带软件源中没有新版本可供更新。
最终我手动添加了新的外部软件源,安装了新版本的gcc,并且写了一个脚本,在打开终端时自动将新版本gcc作为默认编译。