On Mar 13, 2007, at 10:31 AM, Jesse Carpenter wrote: How to set up the build settings in xcode...to "link" libraries to projects? I am experimenting with some ideas using C++ and I want to "link" libxml for example. I located the headers and lib in usr folder under SDKs in developer. The header files and the libxml are in different folders.
Here are the basics for using libraries and headers from standard Unix locations (e.g. /usr)
1) Add /usr to your target's Header Search Paths. (If your header is in a subfolder of /usr, add the path to the folder containing the header.) 2) Add "#include <myHeader.h>" to your source file (where "myHeader" is of course the correct name of the header.) 3) Compile.
The project should compile, but not link.
4) Select the External Frameworks and Libraries group in your project. 5) Control-click on it and choose "Add > Existing Files" 6) In the standard Open Files panel, type / u s r and press Enter 7) Navigate to the library you want to include and press OK. 8) In the following sheet, don't check "Copy into Project Folder," and do check the check box next to the target to which you want to add the library. Click OK. 9) Click Build.
Xcode automatically adds a Library Search Path to the directory containing the library you chose, and adds the library to the project and to the checked target. When you build and link, your code is linked with that library.
Now if you want to build for machines other than the specific architecture/OS of your build machine:
10) Choose Project > Edit Project Settings and click the General tab 11) Choose an SDK from the popup that corresponds to the operating system whose features you want to use (10.4u is the best for now) 12) Close the inspector and Build again.
The Header Search Paths and Library Search Paths will automatically be remapped at build time to point into the SDK's /usr directory instead of the system's.
Important tips: • When adding files, you can type a slash to navigate to paths like /usr that are hidden in the user interface. • You must add a library to the target in order for it to be linked. • Remember to change the search paths in all configurations, not just your current one. • Remember that settings in the Target override settings in the Project. If you have some global characteristic (like what SDK to use), set it at the project level for all configurations. If you have something that distinguishes one build product from another (such as an optimization or debugging flag, or a target-specific preprocessor macro) set it at the target level and on the appropriate configuration.
Chris |