高速C/C++编译工具ccache

ccache的主页:http://ccache.samba.org

在处理大工程时,编译话费时间会比较长,经常需要一遍一遍的编译相同的程序,有了ccache就好多了,尽管在第一遍编译时多花几秒时间,但后续的编译会成倍的提速(5-10倍)。

ccache的原理是通过将头文件高速缓存到源文件中,改进构建性能,因而通过减少每一步编译时添加头文件所需要的时间而提高构建速度;

Ubuntu下配置ccache

【摘自】http://blog.csdn.net/zgl07/article/details/38512845 

①安装ccache

官网下载或apt安装  sudo apt-get install ccache

②$ which ccache

查看安装路径, /usr/bin/ccache

③$ mkdir ~/.bin

④ $ cd ~/.bin/

   $ ln -s /usr/bin/ccache gcc

   $ ln -s /usr/bin/ccache g++

   $ ln -s /usr/bin/ccache arm-linux-gcc

   $ ln -s /usr/bin/ccache arm-linux-g++

⑤PATH设置,将~/.bin/放在 arm-linux-gcc等的PATH的前面。

原:PATH=/usr/local/arm-linux_pre4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

现:PATH=/home/<user>/.bin:/usr/local/arm-linux_pre4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

        gedit ~/.bashrc 添加 export PATH="/home/<user>/.bin:$PAHT" ,然后重启即可

⑥$ which arm-linux-gcc

/home/<user>/.bin/arm-linux-gcc 确认

⑦$ ccache -M 2G

原文地址:https://www.cnblogs.com/haig/p/7873944.html