Xcode dylib constructor destructor

I meant to post this link a while ago, but here it is anyway: TP40002013-SW17 So, in a dylib, you can have code execute when the dylib is loaded and execute code when the dylib is being unloaded: __attribute__((constructor)) static void initializer1() { printf(“[%s] [%s]\n”, __FILE__, __FUNCTION__); } __attribute__((constructor)) static void initializer2() { printf(“[%s] [%s]\n”, … Read more

Changing library dependency paths

If you want to change what your host application is dependent on, without having to rebuild it, you can use the install_name_tool app for changing this: install_name_tool -change oldreference newreference appname install_name_tool -change /usr/lib/libItsAllAboutMe.dylib @executable_path/../Frameworks/libItsAllAboutMe.dylib MySuperApp This is pretty useful for cases where you might have a dynamic library located in a static location, but … Read more