Subject: Re: Inlcuding headers (was: Re: Afterstep & libXpm.4.7)
To: T. Sean <71410.25@compuserve.com>
From: Colin Wood <cwood@ichips.intel.com>
List: port-mac68k
Date: 10/21/1997 17:22:06
T. Sean wrote:
> 
> >For the latter, you need something like either a link in /usr/include
> >named "X11" pointing to the right directory, 
> 
> What I have understood you to say here is that I should put a link to the 
> headers xearth is looking for in the *directory* /usr/include (at first I 
> thought you were talking about a file).  If I understand you correctly 
> then, each time I try to compile something and it cannot find a header 
> file that I have on my system, I should add a link to that header in my 
> /usr/include directory, until presumably every header file called on by 
> every program I have compiled has a link to it in /usr/include?  (I swear 
> I am not being intentionally obtuse.)

Well, most of the includes are like:

<X11/Xos.h>

right?  Then all you need is to do:

ln -s /usr/X11R6/include /usr/include/X11

> Well...OK.  I just started digging through K&R, and on page 152 it says, 
> "When the name is bracketed by < and > a search is made for the header in 
> a standard set of places (for example, on UNIX systems, typically in the 
> directory /usr/include)."  I think I am beginning to get it.
> 
> So, in light of all that above, what you meant here:
> 
> >or you need an
> >-I /some/directory/path/to/a/dir/which/contains/X11 
> >Note: your path should not end w/ X11. An ls of what youput above followed
> >by a "/" and then "X11/file" should find the file.
> >
> 
> is that I could put a link in include to the directory 
> /usr/X11R6/include/X11 so that a compiler could find all of the header 
> files in that directory.  Right?  I just need to make sure the link ends 
> in "/", so that all the headers there can be found.

Well, I don't know about needing a trailing '/', I don't think that's
actually necessary, and it certainly won't actually show up in the name of
the link (since '/' is the one character that can _never_ appear in a Un*x
filename...it would break the filesystem).

> I notice that there are already a few links in /usr/include.  Why are 
> links to the X header files not installed with the X installation?  (Even 
> though their not being included has been of quite some value to my 
> programming and Un*x education!)

They're not installed as links b/c they shouldn't be necessary.  Most well
behaved X applications come with an Imakefile, which, when you run 'xmkmf'
will automatically build a Makefile which has the necessary
"-I/usr/X11R6/include" and "-L/usr/X11R6/lib" lines added to the compile
lines.  Those that don't use imake will usually have a GNU configure
script which is able to figure this kind of thing out.  So, if xearth?
doesn't work this way, it's probably a bit old, or something like that.
You shouldn't ever have to pollute /usr/include with files or directories
which were not shipped with the system.  Include files/directories which
you install yourself should usually go into /usr/local/include (with the
exception of the X11 includes, which go in /usr/X11R6/include...but X is
an entity unto itself).

If you ever run across a program which looks in the wrong place for
includes or libraries, they usually have a Makefile with a few lines you
can edit by hand, usually something like:

INCLUDES=
LIBS=
LDFLAGS=

If xearth has such a Makefile, you can edit the above like so:

INCLUDES=-I/usr/X11R6/include
LIBS=-L/usr/X11R6/lib
LDFLAGS=

(I doubt you need to edit the last one...it's usually ok).

Anyway, I hope this helps some.

Later.

-- 
Colin Wood                                 cwood@ichips.intel.com
Component Design Engineer - MD6                 Intel Corporation
-----------------------------------------------------------------
I speak only on my own behalf, not for my employer.