Posts

Showing posts from May, 2011

Xcode: Easy Shared & Static Lib Management and Linking

Image
In Xcode, you can add existing frameworks (binary shared/static libraries or Apple's packaged framework) to a target in your project by choosing from the framework list or drag'n'drop from Finder. Several libraries under "Frameworks" group (e.g. libBusted.a) Benefit of doing this is obvious: you can manage and see what libraries your program is linked to. However, after doing that, I noticed one thing. Xcode does not link shared/static libraries in a simple way like: gcc -o qux libfoo.dylib libbar.a buz.o Instead, when libraries are going to be added, Xcode obtains paths to the directories containing these libraries, and appends these to the build setting "Library Search Path" of the target. So that the actual linking looks like: gcc -L/path/to/foobar -o qux -lfoo libbar.a buz.o Compared to the former, even though orthodox, linking in the latter is indirect. I like the former method because it's simple and error-free even though it somewh