ldd 依赖项

发布于 2024-12-18 02:17:26 字数 328 浏览 0 评论 0原文

我正在Linux(Ubuntu 11)下编译2个共享库(“A”,“B”),

lib“B”正在使用lib“A”导出的函数(与-lA静态链接)

但是当我运行ldd时在“B”上我只有*

linux-gate.so.1 =>  (0x004c0000) libc.so.6  
/lib/i386-linux-gnu/libc.so.6 (0x00abf000)  
/lib/ld-linux.so.2 (0x00679000)

我看不到我的“A”依赖性!?

奇怪的是,我(几乎)非常确定 ldd 用于显示所有静态依赖项!?

I'm compiling 2 shared libraries ("A", "B") under Linux (Ubuntu 11)

The lib "B" is using exported function from lib "A" (linked statically with -lA)

But when I'm running ldd on "B" I just have*

linux-gate.so.1 =>  (0x004c0000) libc.so.6  
/lib/i386-linux-gnu/libc.so.6 (0x00abf000)  
/lib/ld-linux.so.2 (0x00679000)

I cannot see my "A" dependency !?

Strange, I was (almost) pretty sure ldd used to display ALL static dependencies !?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

友谊不毕业 2024-12-25 02:17:26

来自man ldd

ldd - 打印共享库依赖项

静态库没有运行时依赖关系,因为它们是静态链接的,

From man ldd

ldd - print shared library dependencies

There is no run-time dependencies for static libraries, since they were linked statically,

携君以终年 2024-12-25 02:17:26

您需要动态链接libA.solibB.so,即使用类似的东西构建libB.so

 gcc -shared -o libB.so B*.pic.o -lA 

(假设没有libA.a 存在,只有一个 libA.so

然后您可以使用 ldd libB.so 检查它是否链接了 libA.so

例如,查看大多数 GUI 库,例如/usr/lib/libQtGui.so.4/usr/lib/libgtk-3.so,例如

% ldd /usr/lib/libgtk-3.so
linux-vdso.so.1 =>  (0x00007fffe4cef000)
libgdk-3.so.0 => /usr/lib/libgdk-3.so.0 (0x00007f5a69c3b000)
libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f5a69a00000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f5a696c0000)
libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007f5a694be000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f5a692bc000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f5a690b5000)
libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007f5a68e92000)
libcairo-gobject.so.2 => /usr/lib/libcairo-gobject.so.2 (0x00007f5a68c8a000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0x00007f5a689c9000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f5a687aa000)
libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f5a68465000)
libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f5a68238000)
libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f5a67feb000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f5a67d4d000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f5a67b17000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f5a678c6000)
libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f5a676c3000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f5a674bd000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5a672b5000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f5a66fbe000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5a66d3b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5a66b1f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5a6679b000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f5a66587000)
libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f5a66385000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f5a66176000)
libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f5a65f6d000)
libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f5a65d63000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f5a65b46000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5a65942000)
libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f5a656ba000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f5a65494000)
libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f5a65291000)
libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f5a65087000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f5a64e7d000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f5a64c65000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f5a64a44000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f5a6482e000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f5a64604000)
libffi.so.5 => /usr/lib/x86_64-linux-gnu/libffi.so.5 (0x00007f5a643f7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5a6a50e000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f5a641ba000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f5a63fb7000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f5a63db1000)

You need to link dynamically libA.so into libB.so, that is to build libB.so with something like

 gcc -shared -o libB.so B*.pic.o -lA 

(assuming no libA.a exist, only a libA.so)

And then you could use ldd libB.so to check that it does link libA.so

Look for example into most GUI libraries like /usr/lib/libQtGui.so.4 or /usr/lib/libgtk-3.so, e.g.

% ldd /usr/lib/libgtk-3.so
linux-vdso.so.1 =>  (0x00007fffe4cef000)
libgdk-3.so.0 => /usr/lib/libgdk-3.so.0 (0x00007f5a69c3b000)
libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f5a69a00000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f5a696c0000)
libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007f5a694be000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f5a692bc000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f5a690b5000)
libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007f5a68e92000)
libcairo-gobject.so.2 => /usr/lib/libcairo-gobject.so.2 (0x00007f5a68c8a000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0x00007f5a689c9000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f5a687aa000)
libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f5a68465000)
libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f5a68238000)
libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f5a67feb000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f5a67d4d000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f5a67b17000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f5a678c6000)
libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f5a676c3000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f5a674bd000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5a672b5000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f5a66fbe000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5a66d3b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5a66b1f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5a6679b000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f5a66587000)
libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007f5a66385000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007f5a66176000)
libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007f5a65f6d000)
libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007f5a65d63000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f5a65b46000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5a65942000)
libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007f5a656ba000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f5a65494000)
libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f5a65291000)
libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007f5a65087000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f5a64e7d000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f5a64c65000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f5a64a44000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f5a6482e000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f5a64604000)
libffi.so.5 => /usr/lib/x86_64-linux-gnu/libffi.so.5 (0x00007f5a643f7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5a6a50e000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f5a641ba000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f5a63fb7000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f5a63db1000)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文