public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: newbie looking to add include files
       [not found] <616BE6A276E3714788D2AC35C40CD18DA26EAD@whale.softwire.co.uk>
@ 2003-02-04 18:21 ` Rupert Wood
  0 siblings, 0 replies; 4+ messages in thread
From: Rupert Wood @ 2003-02-04 18:21 UTC (permalink / raw)
  To: 'Mark Petryk'; +Cc: gcc-help

Mark Petryk wrote:

> I would like to add some files to the list of standard include (*.h) 
> files, kind of like a library, to the standard search path of include 
> files.  I see that there are many include files in /usr/include with 
> many sub directories.  Copying my files into yet another sub directory

> under /usr/include did not see to make those files available to the 
> compiler using:

Agree with Eljay, but as an aside: you don't want to do that. Usually:

    * /usr/include (and /usr/lib) belong to the operating system. They
      should come only from the original OS install. You do not mess
      with these files.

      (In particular, some of them may be overridden by GCC's
      "fixincluded" versions and your changes will never be used.)

    * /usr/local/include and /usr/local/lib are for system-wide
      header and library installation. They should be picked up
      automatically (especially on linux distribution installs) but
      you may need to verify that /usr/local/lib is in the
      LD_LIBRARY_PATH environment and that you pass -I and -L
      if necessary.

    * ~/include and ~/lib (i.e. in your home directory) - or
      sometimes ~/local/include and ~/local/lib - are for headers
      and libraries you want to install in your own build
      environment. You will have to add these with -I and -L and
      to LD_LIBRARY_PATH, etc.

If you want to see GCC's built in header search paths, etc., try
compiling something with GCC's -v switch.

> #include <myfile.h>

If you added the subdirectory name, i.e.

    #include <myfiles/myfile.h>

it should have worked.

Rup.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: newbie looking to add include files
@ 2003-02-04 18:19 Mark Petryk
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Petryk @ 2003-02-04 18:19 UTC (permalink / raw)
  To: gcc-help

>
>
>It's far more preferable to do "g++ -I/usr/include/myfiles" in your
>Makefile, than it is to put that kind of cruft in the GCC build itself.
>

I whole-heartedly agree, and about as quick as I asked, I realized that 
if I simply do:

#include <myfiles/myfile.h>

that I am, therefore, specifying the path as I had intended to.  Duh!  
That allows me to put my headers into their own subdirectories and then 
refer to them in a consistent manner.

But, one other question, what if you have *alot* of directories in your 
include search path, and it's something you *need* to put on the g++ 
line?  Don't they get kind of long, and therefore, sort of ugly?  In 
Borland, for instance, I think there is another place to specify 
additional search paths (globally) so that each one of your projects 
benefits from the redirection.  I would like to have my make files 
somewhat generic and not have to specify include paths in that manner, 
should they become unweildy.  Is my thinking wrong about it?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: newbie looking to add include files
  2003-02-04 17:59 Mark Petryk
@ 2003-02-04 18:07 ` John Love-Jensen
  0 siblings, 0 replies; 4+ messages in thread
From: John Love-Jensen @ 2003-02-04 18:07 UTC (permalink / raw)
  To: Mark Petryk, gcc-help

Hi Mark,

You need to rebuild GCC on your platform.  There's a mechanism by which you
can specify (or override) GCC's default include path(s).

I don't have the info at hand, but you can find it on the GCC website.

However, I strongly recommend that you do not do what you are suggesting.

It's far more preferable to do "g++ -I/usr/include/myfiles" in your
Makefile, than it is to put that kind of cruft in the GCC build itself.

Sincerely,
--Eljay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* newbie looking to add include files
@ 2003-02-04 17:59 Mark Petryk
  2003-02-04 18:07 ` John Love-Jensen
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Petryk @ 2003-02-04 17:59 UTC (permalink / raw)
  To: gcc-help

I would like to add some files to the list of standard include (*.h) 
files, kind of like a library, to the standard search path of include 
files.  I see that there are many include files in /usr/include with 
many sub directories.  Copying my files into yet another sub directory 
under /usr/include did not see to make those files available to the 
compiler using:

#include <myfile.h>

I know there are command line parameters to add include paths during 
compiles (-I and the like), but how is it that the compiler knows about 
/usr/include and how does it know to search some of the sub-directories 
in that area.  Is there a configuration file somewhere that I need to 
add my additional path to so that the compiler searches in my directory 
by default?  I'd like to store my header files in a directory like: 
/usr/include/myfiles/myfile.h



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-02-04 18:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <616BE6A276E3714788D2AC35C40CD18DA26EAD@whale.softwire.co.uk>
2003-02-04 18:21 ` newbie looking to add include files Rupert Wood
2003-02-04 18:19 Mark Petryk
  -- strict thread matches above, loose matches on Subject: below --
2003-02-04 17:59 Mark Petryk
2003-02-04 18:07 ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).