Skip to content
Advertisement

how to achieve backward compatibility with missing shared library

I upgrade a program that needs to run on both old and new platform. In the new platform, I have new config so certain functions will not get called in the old platform. However, when I run the program on old platform, it complains missing shared library. What I need is something like “lazyload” or “delayload” mechanism such that when a function is not called the system won’t bother to load its dependent library. But so far I haven’t found a way to achieve it on Linux. I use gcc/c++ with normal link options.

I try simple approach of “-Wl,-z,nodefs” but with error.

/usr/bin/ld: warning: -z nodefs ignored.

So how to enforce it?

Advertisement

Answer

It looks like your particular linker (you didn’t specify which one, but we can guess it might be the default ld.bfd linker) does not support -z nodefs. Try --allow-shlib-undefined to achieve the same result.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement