Recently I had to port one of my projects (link) which so far was only targeting on Linux to Mac OS X. As an important part of the project are loadable C++ modules, I learned about an interesting difference between the two architectures.
Linux uses the ELF binary format for compiled programs and libraries, Mac OS X the Mach-O binary format. This has some consequences for the handling of modules respectively plug-ins. The ELF format does not distinguish between modules and shared libraries, once you compile your code you get output like libfoo.so. If you link with the libfoo library it is loaded on program start (if not already in memory), but you can also load the symbols from libfoo using dlopen.
This is not possible on Mac OS X. The MACH-O binary format used here distinguishes between modules and shared libraries (which usually have the suffix .dylib) . Shared libraries cannot be loaded dynamically as modules using dlopen, and they cannot be unloaded. Modules on the other hand (in Mac terminology they are called ‘bundles’) can be loaded and unloaded the same way as in Linux, but you cannot link against them. Using cmake the solution is to use
add_library(examplePlugin SHARED MODULE examplePlugin.cpp )
in your CMakeLists.txt.

