Monday, July 15, 2019

[Shared Library] How to check the used shared libraries in your program

This post is only to show the command about checking the used shared libraries in your program.

Use ldd to check the dependent shared libraries:
# ldd my program
$ ldd images
linux-vdso.so.1 =>  (0x00007fff8737e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f84b8f59000)
libtflite.so => /usr/local/tf_libs/lib/libtflite.so (0x00007f84b8c2c000)
libtensorflow_cc.so => /usr/local/tf_libs/lib/libtensorflow_cc.so (0x00007f84b3411000)
libtensorflow_framework.so => /usr/local/tf_libs/lib/libtensorflow_framework.so (0x00007f84b25f4000)
libnodes.so => /home/test/danny/nodeeditor-build/lib/libnodes.so (0x00007f84b2327000)
libddskernel.so => /home/test/HDE/x86_64.linux/lib/libddskernel.so (0x00007f84b1f50000)
libdcpsisocpp2.so => /home/test/HDE/x86_64.linux/lib/libdcpsisocpp2.so (0x00007f84b1bf5000)
libQt5Multimedia.so.5 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libQt5Multimedia.so.5 (0x00007f84b18e8000)
libQt5Network.so.5 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libQt5Network.so.5 (0x00007f84b1553000)
libQt5Widgets.so.5 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libQt5Widgets.so.5 (0x00007f84b0d0f000)
libQt5Gui.so.5 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libQt5Gui.so.5 (0x00007f84b0512000)
libQt5Core.so.5 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libQt5Core.so.5 (0x00007f84afdb0000)
libopencv_videoio.so.3.4 => /usr/lib/libopencv_videoio.so.3.4 (0x00007f84afb60000)
libopencv_dnn.so.3.4 => /usr/lib/libopencv_dnn.so.3.4 (0x00007f84aee72000)
libopencv_imgproc.so.3.4 => /usr/lib/libopencv_imgproc.so.3.4 (0x00007f84ac006000)
libopencv_core.so.3.4 => /usr/lib/libopencv_core.so.3.4 (0x00007f84aac94000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f84aa912000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f84aa6fc000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f84aa4df000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f84aa115000)
/lib64/ld-linux-x86-64.so.2 (0x00007f84b915d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f84a9e0c000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f84a9c04000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007f84a9990000)
libpulse-mainloop-glib.so.0 => /usr/lib/x86_64-linux-gnu/libpulse-mainloop-glib.so.0 (0x00007f84a978b000)
libpulse.so.0 => /usr/lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f84a953b000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f84a922a000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f84a9010000)
libicui18n.so.56 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libicui18n.so.56 (0x00007f84a8b77000)
libicuuc.so.56 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libicuuc.so.56 (0x00007f84a87bf000)
libicudata.so.56 => /home/test/Qt5.11.3/5.11.3/gcc_64/lib/libicudata.so.56 (0x00007f84a6ddc000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f84a6bda000)
libopencv_imgcodecs.so.3.4 => /installation/OpenCV-3.4.4/lib/libopencv_imgcodecs.so.3.4 (0x00007f84a62b1000)
libdc1394.so.22 => /usr/lib/x86_64-linux-gnu/libdc1394.so.22 (0x00007f84a603b000)
libavcodec-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56 (0x00007f84a4c08000)
libavformat-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavformat-ffmpeg.so.56 (0x00007f84a4809000)
libavutil-ffmpeg.so.54 => /usr/lib/x86_64-linux-gnu/libavutil-ffmpeg.so.54 (0x00007f84a459a000)
libswscale-ffmpeg.so.3 => /usr/lib/x86_64-linux-gnu/libswscale-ffmpeg.so.3 (0x00007f84a430b000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f84a40e2000)
libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007f84a3edf000)
libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007f84a3cdc000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007f84a3ad5000)
libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007f84a38d2000)
libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007f84a36a1000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f84a348f000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f84a328c000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f84a3086000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f84a2e84000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f84a2b4a000)
libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007f84a2931000)
libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007f84a272c000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f84a250a000)
libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f84a2304000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f84a20f2000)
libpulsecommon-8.0.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-8.0.so (0x00007f84a1e77000)
libjson-c.so.2 => /lib/x86_64-linux-gnu/libjson-c.so.2 (0x00007f84a1c6c000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f84a1a20000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f84a17b0000)
libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f84a1557000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f84a1332000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f84a10bd000)
libjasper.so.1 => /usr/lib/x86_64-linux-gnu/libjasper.so.1 (0x00007f84a0e68000)
libIlmImf-2_2.so.22 => /usr/lib/x86_64-linux-gnu/libIlmImf-2_2.so.22 (0x00007f84a099a000)
libraw1394.so.11 => /usr/lib/x86_64-linux-gnu/libraw1394.so.11 (0x00007f84a078b000)
libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f84a0573000)
libswresample-ffmpeg.so.1 => /usr/lib/x86_64-linux-gnu/libswresample-ffmpeg.so.1 (0x00007f84a0356000)
libva.so.1 => /usr/lib/x86_64-linux-gnu/libva.so.1 (0x00007f84a013a000)
libzvbi.so.0 => /usr/lib/x86_64-linux-gnu/libzvbi.so.0 (0x00007f849feaf000)
libxvidcore.so.4 => /usr/lib/x86_64-linux-gnu/libxvidcore.so.4 (0x00007f849fb9b000)
libx265.so.79 => /usr/lib/x86_64-linux-gnu/libx265.so.79 (0x00007f849ef7c000)
libx264.so.148 => /usr/lib/x86_64-linux-gnu/libx264.so.148 (0x00007f849ebd8000)
libwebp.so.5 => /usr/lib/x86_64-linux-gnu/libwebp.so.5 (0x00007f849e97c000)
libwavpack.so.1 => /usr/lib/x86_64-linux-gnu/libwavpack.so.1 (0x00007f849e753000)
libvpx.so.3 => /usr/lib/x86_64-linux-gnu/libvpx.so.3 (0x00007f849e32f000)
libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f849e086000)
libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f849de5b000)
libvo-amrwbenc.so.0 => /usr/lib/x86_64-linux-gnu/libvo-amrwbenc.so.0 (0x00007f849dc41000)
libvo-aacenc.so.0 => /usr/lib/x86_64-linux-gnu/libvo-aacenc.so.0 (0x00007f849da24000)
libtwolame.so.0 => /usr/lib/x86_64-linux-gnu/libtwolame.so.0 (0x00007f849d801000)
libtheoraenc.so.1 => /usr/lib/x86_64-linux-gnu/libtheoraenc.so.1 (0x00007f849d5c2000)
libtheoradec.so.1 => /usr/lib/x86_64-linux-gnu/libtheoradec.so.1 (0x00007f849d3a8000)
libspeex.so.1 => /usr/lib/x86_64-linux-gnu/libspeex.so.1 (0x00007f849d18f000)
libsnappy.so.1 => /usr/lib/x86_64-linux-gnu/libsnappy.so.1 (0x00007f849cf87000)
libshine.so.3 => /usr/lib/x86_64-linux-gnu/libshine.so.3 (0x00007f849cd7a000)
libschroedinger-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libschroedinger-1.0.so.0 (0x00007f849caa5000)
libopus.so.0 => /usr/lib/x86_64-linux-gnu/libopus.so.0 (0x00007f849c85b000)
libopenjpeg.so.5 => /usr/lib/x86_64-linux-gnu/libopenjpeg.so.5 (0x00007f849c638000)
libopencore-amrwb.so.0 => /usr/lib/x86_64-linux-gnu/libopencore-amrwb.so.0 (0x00007f849c424000)
libopencore-amrnb.so.0 => /usr/lib/x86_64-linux-gnu/libopencore-amrnb.so.0 (0x00007f849c1f9000)
libmp3lame.so.0 => /usr/lib/x86_64-linux-gnu/libmp3lame.so.0 (0x00007f849bf84000)
libgsm.so.1 => /usr/lib/x86_64-linux-gnu/libgsm.so.1 (0x00007f849bd76000)
libcrystalhd.so.3 => /usr/lib/x86_64-linux-gnu/libcrystalhd.so.3 (0x00007f849bb5b000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f849b939000)
libssh-gcrypt.so.4 => /usr/lib/x86_64-linux-gnu/libssh-gcrypt.so.4 (0x00007f849b6f0000)
librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f849b4d4000)
libmodplug.so.1 => /usr/lib/x86_64-linux-gnu/libmodplug.so.1 (0x00007f849b149000)
libgme.so.0 => /usr/lib/x86_64-linux-gnu/libgme.so.0 (0x00007f849aefb000)
libbluray.so.1 => /usr/lib/x86_64-linux-gnu/libbluray.so.1 (0x00007f849acb2000)
libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f849a982000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f849a772000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f849a56e000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f849a368000)
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0 (0x00007f84b92b8000)
libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f849a15e000)
libsndfile.so.1 => /usr/lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f8499ef4000)
libasyncns.so.0 => /usr/lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f8499cee000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f8499ae0000)
libHalf.so.12 => /usr/lib/x86_64-linux-gnu/libHalf.so.12 (0x00007f849989d000)
libIex-2_2.so.12 => /usr/lib/x86_64-linux-gnu/libIex-2_2.so.12 (0x00007f849967f000)
libIlmThread-2_2.so.12 => /usr/lib/x86_64-linux-gnu/libIlmThread-2_2.so.12 (0x00007f8499478000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f84b9295000)
libsoxr.so.0 => /usr/lib/x86_64-linux-gnu/libsoxr.so.0 (0x00007f8499213000)
libnuma.so.1 => /usr/lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f8499008000)
libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f8498dff000)
liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0 (0x00007f8498b7f000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f849889e000)
libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f8498654000)
libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f8498421000)
libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f84981eb000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f8497f6b000)
libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f8497bb0000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f849796d000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f84976c3000)
libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f849745f000)
libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007f849722c000)
libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f8497019000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f8496df7000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f8496bde000)
libFLAC.so.8 => /usr/lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f8496969000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f849674e000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f849652c000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f8496318000)
libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f8496046000)
libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f8495e17000)
libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f8495c13000)
libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f8495a08000)
libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007f8495674000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f849546c000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f8495268000)
libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007f84937b1000)
Use readelf to see which shared library will be loaded into your program and what the rpath contains.
$ readelf --dynamic images

Dynamic section at offset 0xf7a70 contains 45 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libtflite.so]
 0x0000000000000001 (NEEDED)             Shared library: [libtensorflow_cc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libtensorflow_framework.so]
 0x0000000000000001 (NEEDED)             Shared library: [libnodes.so]
 0x0000000000000001 (NEEDED)             Shared library: [libddskernel.so]
 0x0000000000000001 (NEEDED)             Shared library: [libdcpsisocpp2.so]
 0x0000000000000001 (NEEDED)             Shared library: [libQt5Multimedia.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libQt5Network.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libQt5Widgets.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libQt5Gui.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libQt5Core.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_videoio.so.3.4]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_dnn.so.3.4]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_imgproc.so.3.4]
 0x0000000000000001 (NEEDED)             Shared library: [libopencv_core.so.3.4]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
 0x000000000000000f (RPATH)              Library rpath: [/usr/local/tf_libs/lib:/home/test/danny/nodeeditor-build/lib:/home/test/HDE/x86_64.linux/lib:/home/test/Qt5.11.3/5.11.3/gcc_64/lib]
 0x000000000000000c (INIT)               0x449290
 0x000000000000000d (FINI)               0x4ca284
 0x0000000000000019 (INIT_ARRAY)         0x6f2120
 0x000000000000001b (INIT_ARRAYSZ)       240 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x6f2210
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x4002d0
 0x0000000000000005 (STRTAB)             0x4147e8
 0x0000000000000006 (SYMTAB)             0x403af0
 0x000000000000000a (STRSZ)              175303 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x6f8000
 0x0000000000000002 (PLTRELSZ)           15840 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x4454b0
 0x0000000000000007 (RELA)               0x440da0
 0x0000000000000008 (RELASZ)             18192 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x440b20
 0x000000006fffffff (VERNEEDNUM)         12
 0x000000006ffffff0 (VERSYM)             0x43f4b0
 0x0000000000000000 (NULL)               0x0
Notice:
When you add your customed shared library to /lib or /usr/lib, you need to run ldconfig
When you add your customed shared library to other paths, you need to add the path to /etc/ld.so.conf, and then run ldconfig.


Reference:
https://blog.csdn.net/cupidove/article/details/54895618
https://www.jb51.net/article/100233.htm




No comments: