Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • I didnt knpw rpath was a thing in programming. I like the explainations. Under Windows programs always look into their own directory. Now i know, how Linux does handle this. Good answer! Commented Apr 11, 2020 at 19:59
  • I think you have demonstrated that main depends on libone.so due to the link line, rather than that libtwo depends on libone. This is easy to fix by making lib_two.c call foo(). Then moving aside libone.so should cause libtwo.so to fail when main is run. Then the answer will be complete. Commented Apr 11, 2020 at 20:38
  • @casualunixer: sorry, I don't get your point. main doesn't depend on libone.so, it depends on libtwo.so which in turn depends on libone.so. Commented Apr 11, 2020 at 20:55
  • @ArkadiuszDrabczyk, I missed that you included libone.so in the link line for libtwo. Everything is fine. Commented Apr 12, 2020 at 1:02
  • If ./main had libs in its rpath, but libtwo.so didn't, would libone.so still be found when executing ./main? My tests seem to indicate this is the case. So I'm wondering if when loading libtwo.so, the dynamic loader still consults the rpath in ./main. Commented May 14, 2022 at 8:13