'How to build a shared object (.so) with missing dependencies
I would like to build a shared object (let's name it A) that depends on another .so (let's name it B). B is implementing some interface that A is using.
The machine that will load A also has B so when loading A (at load time or via dlopen), it loads B and everything is fine. The issue is that I cannot build B (on the machine I am building A) and therefore cannot build A, since I get a linker error. of course I expect to see B as dependency when doing 'ldd A'.
Is there a linker option to build A without having B?
a picture to visualize my system
Thanks
Solution 1:[1]
The issue is that I cannot build B (on the machine I am building A) and therefore cannot build A, since I get a linker error.
There is a lot of missing info here.
- You have a version of
B.sosomewhere. Why can't you copy that version onto the machine on which you are buildingA.so, and use it to actually buildA.so? - With default linker flags, you should be able to link
A.soeven though it uses symbols fromB.sowithout havingB.soavailable (unresolved symbols are ignored by default when building with-shared).
This will produceA.sowhich doesn't depend onB.so. Atdlopen()time you will simply have to loadB.sowithRTLD_GLOBALbefore loadingA.so. - If you really need to have the
A.so -> B.sodependency, you can create an emptyB.soand link against that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Employed Russian |
