[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
XCode -- how to link in a library statically?
On Nov 17, 2003, at 8:34 PM, Chad Leigh -- ObjectWerks Inc. wrote:
> I would like to link libcurl.a statically into a framework
> (CURLhandle). And not the system provided one, but one I built that I
> know is the right version for my app to run. How can I specify a
> static library that is in /usr/local/lib inside of XCode? I tried
> various "gcc" type thing in the "other linker flags" of the targets
> build prefs but it couldn't find it when linking.
You should be able to just drag the file from the Finder into "Linked
Frameworks." Xcode is smart enough to statically link such things
automatically.
However, if it's in /usr/local/lib, I assume you want it to actually
reside in the Framework bundle at runtime (so that the user doesn't
have to install the library)? Here's what I did for my framework:
1. In the Finder, copy the libcurl.a file to your project directory
2. Drag the file from the project directory to "Linked Frameworks" in
the Xcode window
3. Choose "relative to enclosing group" (the default should be fine)
If you want the library bundled in the framework, you'll also have to
add a copy phase (Project > New Build Phase > Copy Files Phase). The
new copy phase should be visible when you click the triangle next to
your active target. Drag the file from the Frameworks group to the copy
phase, then open the inspector and choose "Frameworks" as the
destination.
If you want a working example, download the DataCrux source from
http://treehouseideas.com/datacrux/.
This caused me a few problems initially, so let me know if you can't
get it working. More here too:
http://cocoadev.com/index.pl?LinkingToExternalLibraries
- Scott
--
Tree House Ideas
http://treehouseideas.com/