Almost every application in Linux uses shared library, even the one compiled by yourself with gcc. You may have realized that application compiled with gcc 4.1 in Fedora or Ubuntu does not able to run under Red Hat ES3 or ES4. Or some other new applications does not able to run at legacy Linux, it is all because of missing shared library dependencies.
Is there any work around solution to allow legacy Linux uses new version of application?
My guess is as long as we resolved those dependencies completely, the application should works under any linux platform, unless the application or its dependencies required kernel version are not match.
Is there any ways to know what shared library are used by a specific application?
We can use ldd. Lets take a simple application for example. I have wrote a fun app uses ncurses library, its call “matrix”. It does nothing but simulate the running characters flow from top to bottom in the movie matrix at your linux console. You may get the source code as well as the binaries at HERE.
ldd matrix linux-gate.so.1 => (0x00110000) libncurses.so.5 => /lib/libncurses.so.5 (0x00111000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0793a000) libm.so.6 => /lib/libm.so.6 (0x0056e000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x0790d000) libc.so.6 => /lib/libc.so.6 (0x00413000) libdl.so.2 => /lib/libdl.so.2 (0x00599000) libtinfo.so.5 => /lib/libtinfo.so.5 (0x00ad0000) /lib/ld-linux.so.2 (0x003f4000)
Observed that, it uses libncurses.so.5. You may find this file in /usr/lib, /usr/share/lib or /lib. Bear in mind, libncurses.so.5 probably is just a symbolic link, you need to copy the real .so instead of its symlink.
The shared library itself sometimes also have dependencies too, which it may also use some other shared library, to fully resolved that, we can add verbose to ldd for more details.
ldd -v matrix ... /lib/libncurses.so.5: libdl.so.2 (GLIBC_2.1) => /lib/libdl.so.2 libdl.so.2 (GLIBC_2.0) => /lib/libdl.so.2 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_2.3.4) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 ...
It seems my ncurses lib uses libdl and glibc.