In my box we have GCC 4.1.2 installed as root user but to compile LLVM and clang I needed a higher version of GCC. So I downloaded and installed GCC 4.5.0 in my local directory.
How can I make existing programs refer to GCC 4.5.0 libs and includes.
> gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> which gcc
/usr/bin/gcc
> setenv PATH gcc-4.5.0/bin/gcc/gcc-4.5.0/bin:$PATH
> gcc --version
gcc (GCC) 4.5.0
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> which gcc
gcc-4.5.0/bin/gcc/gcc-4.5.0/bin/gcc
Is it that just setting the system PATH will help me or is there anything else I need to do for existing code to refer GCC 4.5.0 suite?
gcc-4.5.0/bin/gcc/gcc-4.5.0/> ls -l
total 24
drwxrwxr-x 2 prasad ppusers 4096 Jun 13 21:32 bin
drwxrwxr-x 3 prasad ppusers 4096 Jun 13 21:32 include
drwxrwxr-x 3 prasad ppusers 4096 Jun 13 21:32 lib
drwxrwxr-x 2 prasad ppusers 4096 Jun 13 21:32 lib64
drwxrwxr-x 3 prasad ppusers 4096 Jun 13 21:32 libexec
drwxrwxr-x 6 prasad ppusers 4096 Jun 13 21:32 share
The best way to do this varies greatly by your build system.
For make (and possibly other systems) the C compiler is specified in the CC
variable, so you can just call
CC=/path/to/new/gcc make
if the project uses configure scripts from autoconf, you can use something similar
./configure CC=/path/to/new/gcc