A C++ dependent library .dylib resides in a bundle located in the app package's Content/Frameworks. I'd like to DELAY the loading of that dependent library until I've completed some specific initialization.
Is there any way OTHER THAN to create a Runtime-Loaded Library? Would using weak linking options prevent the .dylib from being loaded until first referenced?
You mean lazy linking:
ld -o test test.o -lazy_library /usr/lib/libz.dylib
ld -o test test.o -lazy-lz
Both load the Zlib compression library when a routine from it is first run. The problem is not to run the routines from your custom library before the initialization is finished.
Weak linking means "if library is missing, set all its symbols to NULLs, don't halt".
NOTICE: replace Zlib (/usr/lib/libz.dylib
) with your library.
来源:https://stackoverflow.com/questions/37197306/os-x-any-way-to-delay-loading-of-a-dependent-library-dylib