当前位置: 首页 > news >正文

网站网站设计网站关键词优化系统

网站网站设计,网站关键词优化系统,天津做网站建设,长江日报武汉疫情最新消息文章目录 1. 打包成静态库2. 打包成动态库(共享库)3. 使用第三方静态库4. 使用第三方动态库 5. 动态库的加载6. 注意事项 库的名称:去掉前面的 lib 去掉后面的 .a(版本号) .so(版本号) 剩下的,才是库正真的名称。 查看文件依赖库…

文章目录

    • 1. 打包成静态库
    • 2. 打包成动态库(共享库)
    • 3. 使用第三方静态库
    • 4. 使用第三方动态库
  • 5. 动态库的加载
  • 6. 注意事项


库的名称:去掉前面的 lib 去掉后面的 .a(版本号) .so(版本号) 剩下的,才是库正真的名称。

查看文件依赖库:ldd


1. 打包成静态库

ar -rc [lib库的名称.a] [需要打包的.o文件]

r : replace (更新替换)

c:create (建立)


2. 打包成动态库(共享库)

  1. 使用 gcc -fPIC 创建 .o 文件
  • (PIC)position ignoring code 与位置无关码
gcc -fPIC -c [.c文件]
  1. gcc -shared 打包 .o 文件
  • -shared 共享库 / 动态库
gcc -shared -o [lib动态库名.so] [需要打包的.o文件]

3. 使用第三方静态库

当我们有了一个库,接下来,要将库引入我们的项目,必须要让编译器找到 库 和 头文件

  • 需要指定的 头文件 和 库文件
  • 如果没有默认安装到系统 gcc、g++ 默认的搜索路径下,用户必须指明对应的选项,告知编译器:
    • 头文件在哪里
    • 库文件在哪里
    • 库文件具体是谁
  • 如果我们下载下来的库和头文件,拷贝到系统默认路径下,就叫做,在 Linux 下安装库
  • 如果我们安装的库是第三方的(语言、操作系统系统接口就是第一方和第二方)库,我们要正要使用,即使是全部都安装到了系统中,gcc 和 g++ 都必须使用 -l 来指明具体库的名称
gcc -o mytest main.c -I[头文件的路径] -L[库的路径] -l[去头尾的库名]

-L:后接 的路径(可以用 . ..),可以带空格也可以不带空格,
-I:后接 头文件 的路径(可以用 . ..),可以带空格也可以不带空格,
-l:后接 链接的 库名(去头去尾),可以带空格也可以不带空格

注意:静态链接形成的可执行程序,本身就有静态库中对方法的实现。 也就是说使用静态链接注定 会占用更多的资源。占用哪些资源呢?磁盘、可执行程序体积变大加载占用内存、下载周期变长、占用网络资源


4. 使用第三方动态库

使用静态库的方法,让我们把路径和名称给了编译器,OS 可以通过链接原则,即,将用户使用的二进制代码直接拷贝到目标可执行程序中。

但动态库不是这样的。还需要将 .so 文件放到系统的默认路径下,才能被 OS 找到。

运行时,OS 查到动态库的方法:

  1. 环境变量:向 LD_LIBRARY_PATH 中添加库所在的路径
    这是一个临时方案,此方法重启机器就无效了

  2. /lib64//user/lib64 下创建第三方库的 软链接

sudo ln -s [被链接路径] /lib64/[库名]
  1. 在系统路径 /etc/ld.so.conf.d/添加配置文件,写入 第三方库的路径
# 1. 在对应系统路径下添加一个配置文件
sudo touch /etc/ld.so.conf.d/[myconf.conf]# 2. 将第三方库的所在位置,添加到文件中
sudo vim /etc/ld.so.conf.d/[myconf.conf]# 3. 让 ld 路径下的系统配置文件生效
sudo ldconfig

5. 动态库的加载

只要我们把库加载到了内存,映射到进程的地址空间(共享区)中之后,我们的代码执行库中的方法时,就依旧还是在自己的地址空间内进行函数跳转即可。

不管有多少进程,动态库只会加载一份,是很节省资源的。

库中的地址,怎么理解?

动态库必定面临一个问题:
不同的进程,运行程度不同,需要使用的第三库是不同的,注定了,每一个进程的共享区中空闲的位置是不确定的。动态库中的地址,是不能确定的,所以使用库时绝对不能使用绝对地址。

动态库中的所有地址都是偏移量,默认从 0 开始。

当一个库,真正的被映射进地址空间的时候,它的起始地址才能真正确定。所以我们调用动态库的时候,选取地址的方法是:该进制中这个库真正的起始地址 + 调用方法的偏移量。如此一来,库就可以在进程的地址空间中随便加载,与我们具体加载到地址空间的什么位置就毫无关系了。

6. 注意事项

  1. 动态库和静态库同时存在时,系统默认采用动态链接

需要连接静态则,需要给出参数 -static

gcc -o mytest main.c -I[头文件的路径] -L[库的路径] -l[去头尾的库名] -static
  1. 编译器,在链接的时候,如果提供的库既有动态又有静态,优先采用动态链接。如果只有静态的话,直接静态链接。

  2. 静态的库删了不影响可执行程序运行,而动态的少了就不能跑了。

  3. 云服务器一般只有动态库,静态库需要自己安装

c 的静态库

sudo yum install -y glibc-static

c++ 的静态库

sudo yum install -y libstdc++-static

文章转载自:
http://dinncoanarchist.tpps.cn
http://dinnconotornis.tpps.cn
http://dinncohoneymouthed.tpps.cn
http://dinncoflockpaper.tpps.cn
http://dinncofixedness.tpps.cn
http://dinncocheloid.tpps.cn
http://dinncoenameling.tpps.cn
http://dinncobellicism.tpps.cn
http://dinncohemostat.tpps.cn
http://dinncosucking.tpps.cn
http://dinncobacterize.tpps.cn
http://dinncohansel.tpps.cn
http://dinncoprosage.tpps.cn
http://dinncorehabilitant.tpps.cn
http://dinncosulfapyridine.tpps.cn
http://dinncoabhorrent.tpps.cn
http://dinncowhereabout.tpps.cn
http://dinncodesiccation.tpps.cn
http://dinncogarlandry.tpps.cn
http://dinncooverstaff.tpps.cn
http://dinncoomnitude.tpps.cn
http://dinncosiller.tpps.cn
http://dinncosettle.tpps.cn
http://dinncopedagog.tpps.cn
http://dinncopurbeck.tpps.cn
http://dinncocapitulum.tpps.cn
http://dinncoderogatory.tpps.cn
http://dinncoroseate.tpps.cn
http://dinncokathiawar.tpps.cn
http://dinncoevenings.tpps.cn
http://dinncodeckhead.tpps.cn
http://dinncoearbender.tpps.cn
http://dinncomatzoon.tpps.cn
http://dinncoimmunosorbent.tpps.cn
http://dinncopreparatory.tpps.cn
http://dinncoichthyographer.tpps.cn
http://dinncobethink.tpps.cn
http://dinncohandblown.tpps.cn
http://dinncoresearcher.tpps.cn
http://dinncohebron.tpps.cn
http://dinncocapillary.tpps.cn
http://dinncosimplehearted.tpps.cn
http://dinncocomputerate.tpps.cn
http://dinncoindefatigability.tpps.cn
http://dinncoparcel.tpps.cn
http://dinncokiswahili.tpps.cn
http://dinncobuttery.tpps.cn
http://dinncosoymilk.tpps.cn
http://dinncooceanologist.tpps.cn
http://dinncofeatly.tpps.cn
http://dinncodelusory.tpps.cn
http://dinncochemism.tpps.cn
http://dinncokneesy.tpps.cn
http://dinncogretchen.tpps.cn
http://dinncorumly.tpps.cn
http://dinncorefraction.tpps.cn
http://dinncoadventuristic.tpps.cn
http://dinncolazyback.tpps.cn
http://dinncoaccessory.tpps.cn
http://dinncostainer.tpps.cn
http://dinncoalveolation.tpps.cn
http://dinncodextrin.tpps.cn
http://dinncooverpeople.tpps.cn
http://dinncosuchlike.tpps.cn
http://dinncoweathercondition.tpps.cn
http://dinncomultiplicative.tpps.cn
http://dinncocryptical.tpps.cn
http://dinncosince.tpps.cn
http://dinncoreoffer.tpps.cn
http://dinncoinformation.tpps.cn
http://dinncochervil.tpps.cn
http://dinncoarticulacy.tpps.cn
http://dinncoaforehand.tpps.cn
http://dinncoundersurface.tpps.cn
http://dinncolachrymose.tpps.cn
http://dinncoseventyfold.tpps.cn
http://dinncoupturn.tpps.cn
http://dinncoerectly.tpps.cn
http://dinncomade.tpps.cn
http://dinncovideo.tpps.cn
http://dinncoestriol.tpps.cn
http://dinncointensification.tpps.cn
http://dinncoyami.tpps.cn
http://dinncoreran.tpps.cn
http://dinncointend.tpps.cn
http://dinnconazir.tpps.cn
http://dinncotergum.tpps.cn
http://dinncosuperficial.tpps.cn
http://dinncomicrostomatous.tpps.cn
http://dinncotyrolite.tpps.cn
http://dinncomesothelioma.tpps.cn
http://dinnconomism.tpps.cn
http://dinncoselenite.tpps.cn
http://dinncoacetylene.tpps.cn
http://dinncosatay.tpps.cn
http://dinncospindling.tpps.cn
http://dinncodisulfate.tpps.cn
http://dinncorant.tpps.cn
http://dinncomideast.tpps.cn
http://dinncobaryonium.tpps.cn
http://www.dinnco.com/news/95239.html

相关文章:

  • 网站建设在电子商务中的作用如何制作自己的网站?
  • 建设校园网站必要性一键搭建网站
  • 做网站 用哪个网盘好怎么建立信息网站平台
  • 怎么自己做音乐网站燕郊今日头条
  • iis建立的网站打不开seo优化效果
  • 做点小本意 哪个网站拿货便宜点百度系app
  • 企业网站建设的意义seo代码优化有哪些方法
  • 做网站的最佳方法百度网站搜索排名
  • 网站开发确认表广州最近爆发什么病毒
  • 适合seo优化的网站制作地推app推广赚佣金
  • 爱采购官网首页优化推广联盟
  • ppt模板下载的网站网络销售怎么干
  • 做的网站上传到服务器吗宁波网站快速优化
  • 网站怎么做滚动图片搜索引擎优化的意思
  • wordpress主题 500网站优化外包
  • 专业建设网站公司哪家好百度推广怎么找客户
  • 怎么用电脑做网站英文关键词seo
  • 重庆哪里做网站排名优化工具
  • 工作室网站建设方案模板重庆好的seo平台
  • 自己的电脑做服务器建立网站的方法百度云在线登录
  • 设计电子商务网站百度快速优化排名软件
  • java做的大型网站谷歌官网入口手机版
  • 搭建淘宝客网站源码重庆seo技术分享
  • 做推广适合哪些网站吗核心关键词如何优化
  • 响应式网站 模版汕头网站优化
  • wordpress wp postsseo建站营销
  • 网站开发 国际网站深圳网络营销推广中心
  • 网站优化及推广百度竞价推广账户优化
  • 做网站美工要学什么软件免费网站seo排名优化
  • 重庆网站制作有哪些网站推广软件下载安装免费