Q) About gcc standard include / lib paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've done quite a bit of searching, and I think I've got most of the
answers I need, but I'm not completely certain, so here goes...
 
I'm trying to set up a new build system at work in which all of our
compilers and tools are checked into our version control system.
We need to do this so that we can insure that any given version of our
product can always be rebuilt with whatever tools were used at the time
(compiler version, headers, etc.)
The intent is to check-in all of the binaries, include files and
libraries that are necessary for a full build of our product from a
command-line.
With Visual Studio, this is pretty straight-forward.  VC has no built-in
logic on where to find include files or libraries.  MS creates a batch
file that sets
the INCLUDE and LIB environment variables appropriately, so it's a
simple matter to check in entire directory trees and update the build
scripts accordingly.
 
As for GCC, I haven't done any *nix programming for close to 20 years,
so I'm virtually starting from scratch.  Bear with me.  
I found a post that mentioned using 'echo "" | gcc -c -E -v -' to
discover the standard include directories.  So far so good.
On my Fedora Core 1 system, this outputs:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
 /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/cc1 -E -quiet -v -D__GNUC__=3
-D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 -
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/include
 /usr/include

Now, I assume that translates to the predefined search order of the
following:
/usr/i386-redhat-linux/include
/usr/local/include
/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/include 
/usr/include 
----- 
So, going through each of those directories:
/usr/i386-redhat-linux/include doesn't exist.  Should it?
/usr/local/include is empty.  Should it be?
/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/include would seem to contain
gcc specific fixed/overridden headers.  Is that correct?
/usr/include
   I assume these are the standard headers included with the os dist and
various add-on packages [kde,etc.], right?
   Would a GCC update ever modify the files here or would they always go
into the gcc-lib/...include directories?

So, correct me if I'm wrong, but it would appear that I can check these
directories into version control (into a common tree) and 
then call my checked in gcc with -nostdinc -nostdinc++ and -I options
for each of my checked in include roots.  Correct so far?

That leaves the libraries *gulp*
My -print-search-dirs output for the libraries is:
libraries:
=/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/:/usr/lib/gcc/i386-redhat-linu
x/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../../i386-redha
t-linux/lib/i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/
3.3.2/../../../../i386-redhat-linux/lib/:/usr/lib/gcc-lib/i386-redhat-li
nux/3.3.2/../../../i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat
-linux/3.3.2/../../../:/lib/i386-redhat-linux/3.3.2/:/lib/:/usr/lib/i386
-redhat-linux/3.3.2/:/usr/lib/

This translates to:

/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/
/usr/lib/gcc/i386-redhat-linux/3.3.2/
/usr/i386-redhat-linux/lib/i386-redhat-linux/3.3.2/
/usr/i386-redhat-linux/lib/
/usr/lib/i386-redhat-linux/3.3.2/
/usr/lib
/lib/i386-redhat-linux/3.3.2/
/lib/
/usr/lib/i386-redhat-linux/3.3.2/
/usr/lib/

Going through these directories:
/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/ exists and contains libgcc*
snd libstdc++* (among others) 
/usr/lib/gcc/i386-redhat-linux/3.3.2/ - doesn't exist
/usr/i386-redhat-linux/lib/i386-redhat-linux/3.3.2/ - doesn't exist
/usr/i386-redhat-linux/lib/ - doesn't exist
/usr/lib/i386-redhat-linux/3.3.2/ - doesn't exist
/usr/lib - yup exists, it looks like pretty much everything is here...
/lib/i386-redhat-linux/3.3.2/ - doesn't exist
/lib - yup - it's there - all the real bins look to be here.
/usr/lib/i386-redhat-linux/3.3.2/ - doesn't exist

So, why all the directories that don't exist?  Are they just there to
provide 'potential' overrides, but there's just nothing to override yet?
Why is /usr/lib added twice? (once directly, and another via the
/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../ entry)


I'm sure I'll have other questions as I go along, but I've got to start
somewhere.

Thanks,
Patrick Bennett



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux