CCache for faster compilation

2018-02-23

I was working on Debian, modifying GPicView. My plan is to let them look a bit like IrfanView.

So I got the sources, changed the source files, and build the package. I know that gcc, make, and some other tools create cache files, but they are thrown away, everytime the package is rebuild.

So I searched 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 you use ccache for all compilations? Well, the question is answered here.

I decided for 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 you check if ccache is used? Compile something and then run:

ccache -s