[{"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}]
一.什么是库文件
库文件是计算机上的一类文件,可以简单的把库文件看成一种代码仓库,它提供给使用者一些可以直接拿来用的变量、函数或类。
◼ 库是特殊的一种程序,编写库的程序和编写一般的程序区别不大,只是库不能单独运行。 ◼
库文件有两种,静态库和动态库(共享库),区别是:静态库在程序的链接阶段被复制 到了程序中;动态库在链接阶段没有被复制到程序中,而是程序在运行时由系统动态加
载到内存中供程序调用。
◼ 库的好处:1.代码保密 2.方便部署和分发
二.静态库
静态库、动态库区别来自链接阶段如何处理,链接成可执行程序。分别称为静态链接方式和动态链接方式。
静态库会在程序链接时被打包到可执行文件中,如果修改了静态库,整个可执行文件都需要重新编译。
2.1静态库制作方法
2.2静态库制作过程
2.3静态库优缺点
三.动态库
2.1动态库制作方法
3.2动态库加载方式
所以在定义动态库之后,需要将其绝对位置加载到系统的环境变量LD_LIBRARY_PATH中或将其移动到系统默认文件夹/lib/,/usr/lib/,或者将其路径添加至/etc/ld.so.cache文件列表。DT_RPATH不可修改,所以不用管。
3.3添加环境变量的方法
采用如下命令可以临时添加,终端关闭后会失效
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:动态库绝对路径
非root用户添加,修改~/.bashrc文件,在文件最下方添加上述命令,并通过 source ~/.bashrc更新文件。
root用户为所有用户添加,即全部用户都能使用,修改/etc/profile文件,将上述命令添加至文件最下方,并source /etc/profile更新文件
3.4动态库的优缺点