One Mach-O feature that strikes many by surprise is the strict distinction between shared libraries and dynamically loaded modules. In ELF systems, both are the same; You can use any part of the general code as a library and dynamic loading. Use otool -hv some_file to see filetype some_file.
The shared Mach-O libraries are of the MH_DYLIB file type and carry the .dylib extension. They can be associated with regular static linker flags, for example. -lfoo for libfoo.dylib. However, they cannot be loaded as a module. (Side note: shared libraries can be loaded dynamically through the API. However, this API differs from the API for bundles and semantics make it useless for dlopen () emulation. In particular, shared libraries cannot be unloaded.) [This is no longer true - you You can use dlopen () with both dylib and bundles. However, dylibs still cannot be unloaded.]
Downloadable modules are called “bundles” in Mach-O speech. They have the file type MH_BUNDLE. Since none of the components care about this, they can carry any extension. The .bundle extension is recommended by Apple, but most ported software products use .so for compatibility. Bundles can be dynamically loaded and unloaded via the dyld API, and there is a wrapper that emulates dlopen () on top of this API. [dlopen is now the preferred API.] Cannot link against packages as if they were shared libraries. However, it is possible that the bundle is linked to real shared libraries; Those will load automatically when you download the package.
To compile a regular shared library on OS X, you must use -dynamiclib and the .dylib extension. -fPIC by default.