CCache for faster compilation

2018-02-23

I was working on Debian, modifying GPicView.

I have to edit and compile the source several times.

I know that it is a time costly process and I know that gcc, make, and some other tools create cache files, but throw them away after the binary is build.

So I looked for a way to keep the cached files, to speed up the building process. And that’s where I found ccache.

From the site:

ccache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again.

Under Debian you install ccache with:

sudo apt-get install ccache

But how do I use ccache for all compilations? The question is answered here.

I decided for a variation of the “symlinks” method:

for tool in /usr/lib/ccache/*
do
  sudo ln -s /usr/bin/ccache /usr/local/bin/$(basename $tool)
done

And after installing I run “which gcc” to make sure that the correct link is being used.

which gcc

How do I check if ccache is working properly? Compile something and then run:

ccache -s