Re: How to specify paths to be searched for #include files
Re: How to specify paths to be searched for #include files
- Subject: Re: How to specify paths to be searched for #include files
- From: Chris Espinosa <email@hidden>
- Date: Thu, 4 Mar 2004 10:48:55 -0800
On Mar 3, 2004, at 1:52 PM, Ken Turkowski wrote:
How do you specify paths to be searched for #included files? I think I
may have done this once, but it's not obvious to me now.
First, you shouldn't have to.
- If you #include standard C or C++ headers, the compiler knows where
(in /usr/include) to look for them automatically.
- If you #include framework headers, you should add the framework to
the project using the Project menu Add Frameworks... command. This
lets Xcode know where the link library is as well as the headers.
- If you #include your own project headers, you should add the headers
to the project with the Project menu Add Files... command. This
ensures the headers are indexed for searching and code completion, and
also puts them under the purview of the SCM system as well.
So the last case is if you #include headers that aren't system,
framework, or project headers, that is, "third-party" headers. The
most portable way to do this is in two steps:
- in Xcode Preferences, Source Trees, add a "source tree" to the root
of the external project, with an absolute path to it on your local disk
and a symbolic name (e.g. "PowerPlant", just to use a common example)
- in your target's Target Inspector, Build tab, Common Settings group,
look for "Header Search Paths". Set its value to
($PowerPlant)/path/to/headers (of course, substituting your own path
This ensures that should you move your external headers, you can
declare their new location just by fixing the Source Trees setting,
rather than having to go through and fix every project that uses them.
It's also great if more than one person is checking out the project,
and they may not all have the external headers in the same place.
Of course, if neither of those apply, you could just add the header
directory path to the "Header Search Paths" setting. It's a UNIX-style
list of space-delimited POSIX paths (remember to quote any paths with,
for example, embedded spaces).
Note also that unlike CodeWarrior, the Header Search Paths are not
recursive. If you have headers in multiple directories you need to
specify each one, not just their common root. This avoids ambiguity
when you have multiple headers with the same name; you're not at the
mercy of file system collation order.
Chris
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.