Loading Dynamic Libraries on Mac

G-Engine uses various third-party libraries: ffmpeg for video playback, fmod for audio playback, zlib for decompression, etc. In all these cases, the library is included as a “dynamic library” (as opposed to a “static library”).

On Windows, when an executable needs a dynamic library, it searches for it in a few predefined locations, such as “the same directory as the executable”. On Mac and Linux, however, the situation is different and requires some consideration and explanation.

I was recently learning how macOS loads dynamic libraries, and it is not as intuitive or well documented as you might hope. This post attempts to lay things out in a clear and easy to digest way.

[Read More]