This is a bit like. There are several posts on the Internet related to this, but I will try to break it in order to “make it work”.
If it is under Linux, then it happened that the application was compiled so that it was not possible to use an external character. The quickest solution is to add the same compilation flags to the main application that are used in the library, that is, add the -fPIC flag to the compilation of the main application, just like the library does.
Instead of using the -Wl,--unresolved-symbols=ignore-all flag -Wl,--unresolved-symbols=ignore-all you should use __attribute__ ((weak)) for the function, for example:
extern "C" void otherThing(size_t) __attribute__ ((weak);
And we check it for NULL at runtime, which allows you to determine whether it was installed or not.
By compiling the main application in the same way as .so , you implicitly allow it to use itself as the target for LD_PRELOAD , as on the manual page:
LD_PRELOAD
A list of additional, user-defined, shared ELF libraries is loaded in front of everyone else. List items can be separated by spaces or colons. This can be used to selectively override functions in other shared libraries .
source share