编译安装ccache(交叉编译器可用)

http://ccache.samba.org/
ccache is a compiler cache. It speeds up recompilation by caching previous
complilations and detecting when the same compilation is being done again.
Supported languages are C, C++, Objective-C and Objective-C++.

作者:帅得不敢出门   群31843264 欢迎c/c++/linuxer前来灌水  转载请保留此信息

tar -xvf ccache-3.1.4.tar.bz2
cd ccache-3.1.4
./configure                                                                     
make                                                                            
make install

默认装在/usr/local/bin/下,而系统默认的gcc装在/usr/bin 下

echo $PATH
/usr/lib/mpi/gcc/openmpi/bin:/home/zengming/bin:/usr/local/bin:/usr/bin:/bin:\
/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin

有两个方法让编译时使用ccache,一就是在编译器名前加ccache,二就是创建链接指向
ccache
上面可知,/usr/local/bin 在/usr/bin 前,我采用的是创建链接的方法,直接在
/usr/local/bin 中创建
    cd /usr/local/bin
    ln -s ccache /usr/local/bin/gcc                                              
    ln -s ccache /usr/local/bin/g++                                              
    ln -s ccache /usr/local/bin/cc                                               
    ln -s ccache /usr/local/bin/c++

我的交叉编译器装在/opt/toolchains/arm920t-eabi/bin/ 下

cd /usr/local/bin/
ln -s ccache /usr/local/bin/arm-linux-gcc
ln -s ccache /usr/local/bin/arm-linux-g++
ln -s ccache /usr/local/bin/arm-linux-c++
ln -s ccache /usr/local/bin/arm-linux-cpp
注意交叉编译时,要确保PATH中 /usr/local/bin 在 交叉编译工具链目录前
这样ccache才有作用

另外如果ccache是装在/usr/bin下面,那么上面的创建链接命令就要改一改,改成全路径

sudo ln -s /usr/bin/ccache /usr/local/bin/gcc                                              
sudo ln -s /usr/bin/ccache /usr/local/bin/g++                                              
sudo ln -s /usr/bin/ccache /usr/local/bin/cc                                               
sudo ln -s /usr/bin/ccache /usr/local/bin/c++

后面的arm-linu-xx也照此改就可以了。

你可能感兴趣的:(gcc,Path,compiler,编译器,caching,compilation)