Loading a library dynamically in Linux or OSX?

You can use dlopen and friends on both Linux and Mac OS X (this Mac man page should work for both). Note, however, that you need to be careful not to mix 32-bit and 64-bit code and libraries; on the Mac, just make sure that the libraries are "universal binaries."


In Linux you use dlopen() (open library), dlsym() (look up a symbol (=function or value, usually)) and friends: http://linux.die.net/man/3/dlopen

I hear it works the same way on OS X, but I have no experience with that.


You are looking for dlopen (analogous to LoadLibrary), dlclose (analogous to FreeLibrary) and dlsym (analogous to GetProcAddress).

Tags:

C++