[ccache] how to use ccache

Francois Marier francois at debian.org
Sat Dec 1 13:04:09 GMT 2007

On 2007-12-01 at 04:51:05, Mahmood NT wrote:
> I saw that, but it says about options and I did not found any thing for compiling usage.
> A I said, I want to force "make" to use ccache. How?

1- Create a directory to add to your path.  For example:

  mkdir /home/mahmood/bin

2- Add it to the FRONT of your path:

  export PATH=/home/mahmood/bin:$PATH

3- Create symlinks of your compiler name into that directory.  For example:

  ln -s /usr/bin/ccache /home/mahmood/bin/c++
  ln -s /usr/bin/ccache /home/mahmood/bin/cc
  ln -s /usr/bin/ccache /home/mahmood/bin/cpp
  ln -s /usr/bin/ccache /home/mahmood/bin/g++
  ln -s /usr/bin/ccache /home/mahmood/bin/g++-4.2
  ln -s /usr/bin/ccache /home/mahmood/bin/gcc
  ln -s /usr/bin/ccache /home/mahmood/bin/gcc-4.2
  ln -s /usr/bin/ccache /home/mahmood/bin/i486-linux-gnu-g++
  ln -s /usr/bin/ccache /home/mahmood/bin/i486-linux-gnu-gcc
  ln -s /usr/bin/ccache /home/mahmood/bin/x86_64-linux-gnu-g++
  ln -s /usr/bin/ccache /home/mahmood/bin/x86_64-linux-gnu-gcc

(You may need to create extra symlinks if your make file is calling any other
gcc binary.)

Then, when you run gcc or g++, it should use ccache instead.  The "which"
command will show you whether or not that's the case:

  $  which gcc


More information about the ccache mailing list