linux源码编译安装ccache

1.下载最新版ccache源码

    wget https://www.samba.org/ftp/ccache/ccache-3.3.4.tar.gz 
    tar zxvf ccache-3.3.4.tar.gz

2.建立编译目录

    mkdir ../build-ccache-3.3.4 
    cd ../build-ccache-3.3.4 

3.配置生成Makefile

    ../ccache-3.3.4/configure 

4.修改Makefile并编译

    CFLAGS和CPPFLAGS修改参数: 
    CFLAGS = -g -O3 -Wall -W -march=native
    CPPFLAGS = -g -O3 -Wall -W -march=native
    make -j`getconf _NPROCESSORS_ONLN` 

5.安装

    sudo make install 

6. 查看是否安装成功

    ccache  --version && which ccache && whereis ccache
    > ccache version 3.3.4 
    > Copyright (C) 2002-2007 Andrew Tridgell
    > Copyright (C) 2009-2017 Joel Rosdahl
    > This program is free software; you can redistribute it and/or modify it under
    > the terms of the GNU General Public License as published by the Free Software
    > Foundation; either version 3 of the License, or (at your option) any later
    > version. 
    > /usr/local/bin/ccache
    > ccache: /usr/local/bin/ccache /usr/local/etc/ccache.conf

7. 创建软链接启用ccache

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

8.配置

    创建$HOME/.ccache/ccache.conf并添加  
            max_size = 5G
            cache-dir = /dev/shm/tmp/ccache
    查看
            ccache -s
    清理
            ccache -C

9.使用

    ccache gcc xx.c -o a.out 
    ccache make -j`getconf _NPROCESSORS_ONLN`

官网参考

    https://ccache.samba.org/manual.html

转载于:https://my.oschina.net/ajebs/blog/1554199

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值