加入收藏 | 设为首页 | 会员中心 | 我要投稿 大庆站长网 (https://www.0459zz.com/)- 科技、智能边缘云、事件网格、云计算、站长网!
当前位置: 首页 > 综合聚焦 > Linux > 正文

linux – 库部署与未使用的直接依赖关系

发布时间:2020-11-14 13:08:56 所属栏目:Linux 来源:互联网
导读:我试图找出Qt Assistant需要部署的库.我在Linux上使用了ldd.我发现ldd提供了一个选项-u来“打印未使用的依赖项”.这听起来像是某种依赖(部署)不需要(总是).所以我再运行了两个ldd命令:~$ldd -u ~/Qt/5.10.0/gcc_64/bin/assistant Unused direct dependencies

我试图找出Qt Assistant需要部署的库.我在Linux上使用了ldd.

我发现ldd提供了一个选项-u来“打印未使用的依赖项”.这听起来像是某种依赖(部署)不需要(总是).所以我再运行了两个ldd命令:

~$ldd -u ~/Qt/5.10.0/gcc_64/bin/assistant 
Unused direct dependencies:
        /lib/x86_64-linux-gnu/libQt5Network.so.5
        /lib/x86_64-linux-gnu/libQt5Sql.so.5
        /lib/x86_64-linux-gnu/mesa/libGL.so.1
        /lib/x86_64-linux-gnu/libpthread.so.0
        /lib/x86_64-linux-gnu/libm.so.6
        /lib/x86_64-linux-gnu/libgcc_s.so.1

~$ldd -r -u ~/Qt/5.10.0/gcc_64/bin/assistant 
Unused direct dependencies:
        /lib/x86_64-linux-gnu/libQt5Network.so.5
        /lib/x86_64-linux-gnu/mesa/libGL.so.1
        /lib/x86_64-linux-gnu/libpthread.so.0
        /lib/x86_64-linux-gnu/libm.so.6
        /lib/x86_64-linux-gnu/libgcc_s.so.1

我试图找出发生了什么,但我并没有完全理解它.

我的问题是:

>什么是未使用的直接依赖(这听起来很矛盾
我)?
>是否有可能找出Qt Assistant是否真的需要未使用
直接依赖(其他然后启动它并等待错误)?
>上述命令行之间究竟有什么区别?为什么
第一个列表libQt5Sql但第二个列表没有? 最佳答案 由于-u开关打印.
在ldd的手册页中

-u,--unused
          Print unused direct dependencies.  (Since glibc 2.3.4.)

What is an unused direct dependency (this sounds contradictory to me)?

这是恕我直言 – >你建立二进制文件库是不必要的.

gcc -L

它会将所有A B C列为依赖项,但它们实际上可能不会用于二进制文件.
主要原因是Makefile中的通用LDFLAGS.

Is it possible to find out if Qt Assistant actually requires an unused
direct dependency (other then starting it and waiting for an error)?

不,我认为,因为只有在您调用特定功能时才可以使用它.
也有可能你可以使用这个不会看到错误.
如果你决定这样做仍然.有一种疯狂的方式.列出所有调用的函数,然后检查所需的库. (不确定这个,但我认为基于类似的逻辑ldd打印这个.)
根据man page ldd可能运行二进制文件.所以基本上可以是你提到的场景.但并不广泛.

 Be aware,however,that  in some circumstances,some versions of
 ldd may attempt to obtain the dependency information by directly 
 executing  the program.  Thus,you should never employ ldd on an
 untrusted executable,since this may result in the execution  of  arbitrary  code.

What exactly is the difference between the above command lines? Why
does the first list libQt5Sql but the second doesn’t?

差异是-r

       -r,--function-relocs
          Perform relocations for both data  objects  and  functions,and
          report any missing objects or functions (ELF only).

简而言之,它处理加载的库函数.
建议在redhat上的this bug中使用ldd -u -r.
要了解有关重定位处理的更多信息,请阅读this oracle doc.

(编辑:大庆站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读