Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?Confusion about linking boost library while compilationIs it possible to configure dynamic loader for an executableI am getting an error while loading shared libraries libXm.so.3Satisfying lib dependencyError while building snipersim: “relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC”How do I find the libraries this program needs for its environment variable?How to regain access to the lost user , linux3 , of two side by side Ubuntu 16.04 instances?Where do C# executables running on an Ubuntu Linux 16.04 desktop which use source code that DLLImport's shared objects look for them at runtime?Cannot find shared object file even though it's in library pathPlaced library in /usr/lib, but ldconfig doesn't put it in cache

Is there a familial term for apples and pears?

Is ipsum/ipsa/ipse a third person pronoun, or can it serve other functions?

Are cabin dividers used to "hide" the flex of the airplane?

Where to refill my bottle in India?

What do the Banks children have against barley water?

Does it makes sense to buy a new cycle to learn riding?

Why is it "Tumoren" and not "Tumore"?

Why isn't airport relocation done gradually?

What happens when a metallic dragon and a chromatic dragon mate?

Would Tezos benefit from parallelisation?

How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?

Domain expired, GoDaddy holds it and is asking more money

Information to fellow intern about hiring?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

How are circuits which use complex ICs normally simulated?

Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?

Is it wise to focus on putting odd beats on left when playing double bass drums?

Is this food a bread or a loaf?

Dual Citizen. Exited the US on Italian passport recently

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

Is "plugging out" electronic devices an American expression?

What are the advantages and disadvantages of running one shots compared to campaigns?

aging parents with no investments

How can I plot a Farey diagram?



Why don't Unix/Linux systems traverse through directories until they find the required version of a linked library?


Confusion about linking boost library while compilationIs it possible to configure dynamic loader for an executableI am getting an error while loading shared libraries libXm.so.3Satisfying lib dependencyError while building snipersim: “relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC”How do I find the libraries this program needs for its environment variable?How to regain access to the lost user , linux3 , of two side by side Ubuntu 16.04 instances?Where do C# executables running on an Ubuntu Linux 16.04 desktop which use source code that DLLImport's shared objects look for them at runtime?Cannot find shared object file even though it's in library pathPlaced library in /usr/lib, but ldconfig doesn't put it in cache






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I have a binary executable named "alpha" that requires a linked library (libz.so.1.2.7) which is placed at /home/username/myproduct/lib/libz.so.1.2.7



I export the same to my terminal instance before spawning my binary executable by executing the following command.



export LD_LIBRARY_PATH=/home/username/myproduct/lib/:$LD_LIBRARY_PATH


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_1.2.3.3' 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?










share|improve this question









New contributor




daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • I'm not quite sure, but I'd guess for security. I personally would rather not have to worry about a sym-link anywhere on my machines

    – Joe
    5 hours ago











  • @Joe Many of the libraries themselves have symlinks pointing to them. libz.so.1 is a symlink to libz.so.1.2.8

    – Nasir Riley
    4 hours ago

















5















I have a binary executable named "alpha" that requires a linked library (libz.so.1.2.7) which is placed at /home/username/myproduct/lib/libz.so.1.2.7



I export the same to my terminal instance before spawning my binary executable by executing the following command.



export LD_LIBRARY_PATH=/home/username/myproduct/lib/:$LD_LIBRARY_PATH


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_1.2.3.3' 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?










share|improve this question









New contributor




daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • I'm not quite sure, but I'd guess for security. I personally would rather not have to worry about a sym-link anywhere on my machines

    – Joe
    5 hours ago











  • @Joe Many of the libraries themselves have symlinks pointing to them. libz.so.1 is a symlink to libz.so.1.2.8

    – Nasir Riley
    4 hours ago













5












5








5








I have a binary executable named "alpha" that requires a linked library (libz.so.1.2.7) which is placed at /home/username/myproduct/lib/libz.so.1.2.7



I export the same to my terminal instance before spawning my binary executable by executing the following command.



export LD_LIBRARY_PATH=/home/username/myproduct/lib/:$LD_LIBRARY_PATH


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_1.2.3.3' 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?










share|improve this question









New contributor




daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have a binary executable named "alpha" that requires a linked library (libz.so.1.2.7) which is placed at /home/username/myproduct/lib/libz.so.1.2.7



I export the same to my terminal instance before spawning my binary executable by executing the following command.



export LD_LIBRARY_PATH=/home/username/myproduct/lib/:$LD_LIBRARY_PATH


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_1.2.3.3' 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?







libraries dynamic-linking shared-library ld






share|improve this question









New contributor




daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 50 mins ago









Stephen Kitt

180k25411492




180k25411492






New contributor




daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 5 hours ago









daedalus_hamletdaedalus_hamlet

313




313




New contributor




daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






daedalus_hamlet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • I'm not quite sure, but I'd guess for security. I personally would rather not have to worry about a sym-link anywhere on my machines

    – Joe
    5 hours ago











  • @Joe Many of the libraries themselves have symlinks pointing to them. libz.so.1 is a symlink to libz.so.1.2.8

    – Nasir Riley
    4 hours ago

















  • I'm not quite sure, but I'd guess for security. I personally would rather not have to worry about a sym-link anywhere on my machines

    – Joe
    5 hours ago











  • @Joe Many of the libraries themselves have symlinks pointing to them. libz.so.1 is a symlink to libz.so.1.2.8

    – Nasir Riley
    4 hours ago
















I'm not quite sure, but I'd guess for security. I personally would rather not have to worry about a sym-link anywhere on my machines

– Joe
5 hours ago





I'm not quite sure, but I'd guess for security. I personally would rather not have to worry about a sym-link anywhere on my machines

– Joe
5 hours ago













@Joe Many of the libraries themselves have symlinks pointing to them. libz.so.1 is a symlink to libz.so.1.2.8

– Nasir Riley
4 hours ago





@Joe Many of the libraries themselves have symlinks pointing to them. libz.so.1 is a symlink to libz.so.1.2.8

– Nasir Riley
4 hours ago










1 Answer
1






active

oldest

votes


















10















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?




It does, as far as it’s aware. zlib.so.1.2.7 and zlib.so.1.2.8 both have an soname of zlib.so.1, so your alpha and bravo binaries say they need zlib.so.1. The dynamic loader loads the first matching library it finds; it doesn’t know that version 1.2.8 provides additional symbols which bravo needs. (This is why distributions take pains to specify additional dependency information, such as zlib1g (>= 1.2.8) for bravo.)



You might think this should be easy to fix, but it isn’t, not least because binaries and libraries list the symbols they need separately from the libraries they need, so the loader can’t check that a given library provides all the symbols that are needed from it. Symbols can be provided in a variety of ways, and introducing a link between symbols and the libraries providing them could break existing binaries. There’s also the added fun of symbol interposition to complicate things (and make security-sensitive developers tear their hair out).



Some libraries provide version information which ends up being stored in .gnu.version_r, with a link to the providing library, which would help here, but libz isn’t one of them.



(Given the sonames, I’d expect your alpha binary to work fine with zlib.so.1.2.8.)






share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    daedalus_hamlet is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511380%2fwhy-dont-unix-linux-systems-traverse-through-directories-until-they-find-the-re%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10















    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?




    It does, as far as it’s aware. zlib.so.1.2.7 and zlib.so.1.2.8 both have an soname of zlib.so.1, so your alpha and bravo binaries say they need zlib.so.1. The dynamic loader loads the first matching library it finds; it doesn’t know that version 1.2.8 provides additional symbols which bravo needs. (This is why distributions take pains to specify additional dependency information, such as zlib1g (>= 1.2.8) for bravo.)



    You might think this should be easy to fix, but it isn’t, not least because binaries and libraries list the symbols they need separately from the libraries they need, so the loader can’t check that a given library provides all the symbols that are needed from it. Symbols can be provided in a variety of ways, and introducing a link between symbols and the libraries providing them could break existing binaries. There’s also the added fun of symbol interposition to complicate things (and make security-sensitive developers tear their hair out).



    Some libraries provide version information which ends up being stored in .gnu.version_r, with a link to the providing library, which would help here, but libz isn’t one of them.



    (Given the sonames, I’d expect your alpha binary to work fine with zlib.so.1.2.8.)






    share|improve this answer





























      10















      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?




      It does, as far as it’s aware. zlib.so.1.2.7 and zlib.so.1.2.8 both have an soname of zlib.so.1, so your alpha and bravo binaries say they need zlib.so.1. The dynamic loader loads the first matching library it finds; it doesn’t know that version 1.2.8 provides additional symbols which bravo needs. (This is why distributions take pains to specify additional dependency information, such as zlib1g (>= 1.2.8) for bravo.)



      You might think this should be easy to fix, but it isn’t, not least because binaries and libraries list the symbols they need separately from the libraries they need, so the loader can’t check that a given library provides all the symbols that are needed from it. Symbols can be provided in a variety of ways, and introducing a link between symbols and the libraries providing them could break existing binaries. There’s also the added fun of symbol interposition to complicate things (and make security-sensitive developers tear their hair out).



      Some libraries provide version information which ends up being stored in .gnu.version_r, with a link to the providing library, which would help here, but libz isn’t one of them.



      (Given the sonames, I’d expect your alpha binary to work fine with zlib.so.1.2.8.)






      share|improve this answer



























        10












        10








        10








        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?




        It does, as far as it’s aware. zlib.so.1.2.7 and zlib.so.1.2.8 both have an soname of zlib.so.1, so your alpha and bravo binaries say they need zlib.so.1. The dynamic loader loads the first matching library it finds; it doesn’t know that version 1.2.8 provides additional symbols which bravo needs. (This is why distributions take pains to specify additional dependency information, such as zlib1g (>= 1.2.8) for bravo.)



        You might think this should be easy to fix, but it isn’t, not least because binaries and libraries list the symbols they need separately from the libraries they need, so the loader can’t check that a given library provides all the symbols that are needed from it. Symbols can be provided in a variety of ways, and introducing a link between symbols and the libraries providing them could break existing binaries. There’s also the added fun of symbol interposition to complicate things (and make security-sensitive developers tear their hair out).



        Some libraries provide version information which ends up being stored in .gnu.version_r, with a link to the providing library, which would help here, but libz isn’t one of them.



        (Given the sonames, I’d expect your alpha binary to work fine with zlib.so.1.2.8.)






        share|improve this answer
















        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?




        It does, as far as it’s aware. zlib.so.1.2.7 and zlib.so.1.2.8 both have an soname of zlib.so.1, so your alpha and bravo binaries say they need zlib.so.1. The dynamic loader loads the first matching library it finds; it doesn’t know that version 1.2.8 provides additional symbols which bravo needs. (This is why distributions take pains to specify additional dependency information, such as zlib1g (>= 1.2.8) for bravo.)



        You might think this should be easy to fix, but it isn’t, not least because binaries and libraries list the symbols they need separately from the libraries they need, so the loader can’t check that a given library provides all the symbols that are needed from it. Symbols can be provided in a variety of ways, and introducing a link between symbols and the libraries providing them could break existing binaries. There’s also the added fun of symbol interposition to complicate things (and make security-sensitive developers tear their hair out).



        Some libraries provide version information which ends up being stored in .gnu.version_r, with a link to the providing library, which would help here, but libz isn’t one of them.



        (Given the sonames, I’d expect your alpha binary to work fine with zlib.so.1.2.8.)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 4 hours ago

























        answered 4 hours ago









        Stephen KittStephen Kitt

        180k25411492




        180k25411492




















            daedalus_hamlet is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            daedalus_hamlet is a new contributor. Be nice, and check out our Code of Conduct.












            daedalus_hamlet is a new contributor. Be nice, and check out our Code of Conduct.











            daedalus_hamlet is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511380%2fwhy-dont-unix-linux-systems-traverse-through-directories-until-they-find-the-re%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            acmart: Multiple authors: all with same affiliation, one author an additional affiliationHow to Write Names of Multiple Authors with Shared Affiliation in ACM 2017 Template?Multiple authors with different primary affiliation, but same additional affiliationSame affiliation for all authors without extra packagesIOS-Book-Article.cls: one author with multiple affiliationacmart: Shared Author AffiliationMultiple authors with different primary affiliation, but same additional affiliationAuthor affiliation with only 1 authorAdding Multiple Authors with Different Affiliation in LaTeX ArticleLaTeX: Multiple authors stays on same lineHow to Label Multiple Authors with Same DescriptionHow to make two authors use the same affiliationTwo authors with same affiliation on finished front page

            How to write “ä” and other umlauts and accented letters in bibliography?Accents in BibTeXSorting references with special characters alphabeticallyUse ae ligature in bibliographyEastern European nameInverted circumflex in BibTexBibTex, non-ascii initials and nameptr fproblems with accent in LatexHow to add a Ø to my bibliography from Jabref?References without accentsTroubles when trying to cite St“omer-Verlet in ”title" field of a bib entryComprehensive list of accented charactersHow to type the letter “i” with two dots (diaeresis) in math mode?Problem with glossary text and accented lettersSpecial character in bibliographyAccented letters, Unicode and LaTeX accentsHow to stop natbib from modifying bibliography styleCitation of a paper with non-standard characters by BibtexWrite accented characters to file using writeHow to group the bibliography alphabetically, if some surnames start with “accented” characters?How can I automatically capitalize significant words in my bibliography?

            Problem using RevTeX4-1 with “! Undefined control sequence. @bibitemShut”