0

I am running into the following situation. Project A has libraries A1, A2, A3... That follow their own directory structure. For example:

Libaries/
|
|--Dir1/
|  |
|  |--A1.so
|  |--A2.so
|
|--Dir2/
|  |--A3.so
|  |--A4.so

In this case Project A compiles just fine. The libraries of project A are dependencies for project B and a script (that I have no control over) copies them onto B's directory in a flat hierarchy i.e this

BLibraries/
|--A1.so
|--A2.so
|--A3.so
|--A4.so

So the relative paths are no longer the same.

B loads symbols from these libraries dynamically through dlopen. In this case, If A1 needs symbols from A2, B they appear as undefined and so B fails to load A1.

Is there a way I can poke the files Ai.so and tell them "Hey that other library whose symbols you need is actually over here now"?

Makogan
  • 8,208
  • 7
  • 44
  • 112
  • 1
    This looks promising: https://stackoverflow.com/questions/13769141/can-i-change-rpath-in-an-already-compiled-binary If it works, I'll close the question as a dup. – Paul Sanders May 05 '22 at 19:46

1 Answers1

1

Is there a way I can poke the files Ai.so and tell them "Hey that other library whose symbols you need is actually over here now"?

You can use patchelf to do that, but you shouldn't.

Since you control how A*.so is built, you should set their RPATH so that it works "out of the box". Adding -rpath=/path/to/BLibraries to A*.so link command is probably all that's needed.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362