[英]Library deployment vs unused direct dependencies
I tried to find out which libraries Qt Assistant
needs for deployment. 我试图找出
Qt Assistant
需要部署的库。 I used ldd
on Linux for this. 我在Linux上使用了
ldd
。
I found that ldd
provides an option -u
to "print unused dependencies". 我发现
ldd
提供了一个选项-u
来“打印未使用的依赖项”。 This sounds like there is some kind of dependency that is not (always) needed for deployment. 这听起来像是某种依赖(部署)不需要(总是)。 So I ran two more
ldd
commands: 所以我再运行了两个
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
I tried to find out what is going on but I didn't fully understand it. 我试图找出发生了什么,但我并没有完全理解它。
My questions are: 我的问题是:
Qt Assistant
actually requires an unused direct dependency (other then starting it and waiting for an error)? Qt Assistant
真的需要一个未使用的直接依赖(除了启动它并等待错误)? libQt5Sql
but the second doesn't? libQt5Sql
而第二个列表没有? It is printing because of -u switch. 由于-u开关打印。 in man page of ldd
在ldd的手册页中
-u, --unused
Print unused direct dependencies. (Since glibc 2.3.4.)
What is an unused direct dependency (this sounds contradictory to me)?
什么是未使用的直接依赖(这听起来与我相矛盾)?
It is IMHO -> Library you built binary which was not necessary. 是恕我直言 - >你建立了二进制的图书馆,没有必要。 ie
即
gcc -L<LD_PATH> -Wall -o assistant assistant.c -lA -lB -lC
it will list all ABC as dependency but they may not be actually used in binary. 它会将所有ABC列为依赖项,但它们实际上可能不会用于二进制文件。 Mostly the cause is universal LDFLAGS in Makefile.
主要原因是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)?
是否有可能找出Qt Assistant是否真的需要一个未使用的直接依赖(除了启动它并等待错误)?
NO I think as it may be used only when you will call particular function. 不,我认为,因为只有在您调用特定功能时才可以使用它。 there is also a chance you can use this an won't see error.
也有可能你可以使用这个不会看到错误。 Still if you decides to do so.
如果你决定这样做仍然。 there is a insane way.
有一种疯狂的方式。 listing all functions called and then checking which all libraries are need.
列出所有调用的函数,然后检查所需的库。 (no sure of this but I think based on similar logic ldd prints this.) according man page ldd may run binary.
(不确定这个,但我认为基于类似的逻辑ldd打印这个。)根据man page ldd可能运行二进制文件。 So basically can be a scenario you mentioned.
所以基本上可以是你提到的场景。 but not extensively.
但并不广泛。
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?
为什么第一个列表libQt5Sql而第二个列表没有?
Differance is -r
差异是
-r
-r, --function-relocs
Perform relocations for both data objects and functions, and
report any missing objects or functions (ELF only).
In short it processes loaded library functions. 简而言之,它处理加载的库函数。 It is suggested to use
ldd -u -r
in this bug on redhat. 建议在redhat上的这个 bug中使用
ldd -u -r
。 to know more about Relocation Processing read this oracle doc. 要了解有关重定位处理的更多信息,请阅读此 oracle doc。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.