Re: Including external Header files
Re: Including external Header files
- Subject: Re: Including external Header files
- From: Phil Hystad <email@hidden>
- Date: Fri, 17 Aug 2007 11:29:49 -0700
Chris,
Thanks for the help. I had already discovered the Header Search
Paths in the build settings. But, I did not know about the slippery
use of ~ for user home. I will define externals path as you suggest.
However, is there documentation on this sort of thing. Finding this
type of information, such as the "proper" way to define a header
search path is not easy. Yes, I did read the documentation but I
could have missed something.
phil
On Aug 17, 2007, at 11:23 AM, Chris Espinosa wrote:
On Aug 16, 2007, at 7:23 PM, Phil Hystad wrote:
I am attempting to compile a C++ project that I have been setting
up in Xcode. This rather large C++ project consists of #include
statements for standard library header files, for header files
that are part of the project, and external header files that are
not part of the project and not found in any of the standard
search paths.
So, how do I configure Xcode to find these external header files.
Let's assume the following:
(1) Include statement looks like this:
#include "libx/header1.h"
#include "libx/header2.h"
(2) And, the headers of libx are defined in the following path:
~/Documents/work/externals/libx
My first attempt is to define a compiler directive as follows:
-I~/Documents/work/externals
So that the subdirectory reference in the include "libx/" would
properly be found
by that particular path.
This does not work. I still get errors that the include files
cannot be found.
I also tried creating a group and adding the include files of libx
as a reference but
this did not work. But, I am not surprised since I am not sure
how the subdirectory
reference of the #include statement gets properly resolved.
So, can you help. How are you supposed to handle such a thing.
Putting these header files directly into the source files of the
project source is not acceptable. There must be a way to handle
this on an external reference.
Expanding ~ (like . and ..) is fragile and unreliable. Xcode has a
concept of "source trees" which you can use for this purpose.
1) In Xcode > Preferences > Source Trees, define a source tree that
points to /Users/phystad/Documents/work/externals with the name,
say, "EXTERNALS"
2) In your project, add to the Header Search Paths the path $
{EXTERNALS}
Others who download or check out your project can put their
externals wherever they want, and just define EXTERNALS in their
own Xcode preferences to point to it, and the project will work.
The three errors in the above attempt:
1) Xcode uses direct system calls to execute build commands, it
doesn't use shell interpretation, Tilde, globbing, pipes,
backticks, etc. don't have any effect in build settings.
2) Using your home directory is inherently fragile. For example,
sudo xcodebuild will build your project as root, and both ~ and $
{HOME} will be different, and your build will fail.
3) Don't put -I directives into Other C Flags. Use the Header
Search Paths build setting; that way other parts of Xcode (not just
the compiler) see where you want to look for headers.
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden