How I like to code

Tag Archives: dylib

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: ?View Code C__attribute__((constructor)) static void initializer1() { printf("[%s] [%s]\n", __FILE__, __FUNCTION__); }   __attribute__((constructor)) static void initializer2() […]

C++ tips and tricks for MacOS X

I had to do some fancy debugging of a C++ dylib and while I was searching around the internet, I came accross this article from Apple: C++ features in MacOS X. I also found two cool articles that describe well how the dlopen application works and what happens to your symbols when an application bundle […]


I found this useful tool, thanks to my coworker, that is an alternative to using the otool tool: MacDependency

How do I know if a method is available?

The Mac OS supports, and has for a long time now, methods for checking whether or not you have functionality available to you from the SDK or from a class that was built by another developer. This may be compared to COM, which is fair, but the implementation is much richer.

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 […]

Xcode and static libs

I’m writing this blog entry just in case other people come across the same problem and can’t seem to figure out what’s going on. I found it in Xcode 2.5 that hasn’t been fixed in the latest version of Xcode that I have, version 3.1.3. The bug I’m referring to is when you create a […]

Dumping symbols from a library

When you need to dump symbols from a dylib on Mac OS or a DLL on Windows, you can use the following commands to do so: Mac OS nm -m mySpecialLibrary.dylib Windows dumpbin /exports┬ámySpecialLibrary.dll Now sometimes, you have have a lot of symbols in one library, or you may want to find one particular symbol. […]