I have a binary executable named "alpha" that requires a linked library (libz.so.1.2.7) which is placed at
I export the same to my terminal instance before spawning my binary executable by executing the following command.
Now, when I spawn another application "bravo" that requires the same library but of different version, i.e (libz.so.1.2.8) which is available in
/lib/x86_64-linux-gnu/libz.so.1.2.8, system throws the following error.
version `ZLIB_18.104.22.168' not found (required by /usr/lib/x86_64-linux-gnu/libxml2.so.2)
If I unset the
LD_LIBRARY_PATH, "bravo" starts up fine. I understand that the above behaviour is because
LD_LIBRARY_PATH takes precedence over the directory paths defined in
/etc/ld.so.conf while looking for linked libraries and consequently the above error occurred. I am just curious about why have not the developers of UNIX/LINUX designed the OS to search for linked libraries in other directories according to the hierarchy if the first instance of library is of different version.
Simply put, UNIX/LINUX systems traverse through a set of directories until it finds the required library. But why does it not do the same until it finds the expected version rather than accepting the first instance of library irrespective of its version?
libz.so.1is a symlink to