1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <dlfcn.h> void myinit() __attribute__((constructor)); void myinit() { // call dlopen() in initializer void* handle = dlopen(RUN_DIR "/libbar.dylib", RTLD_LAZY); } int foo() { return 0; }