That depends on executables (such as your own main program) and shared libraries (what dlopen() reads) having the same file format. That's a feature of the ELF executable format commonly used on Linux systems, but isn't necessarily true of other executable formats, like MachO (used on OS X).