使用 ccache 优化c/c++ 编译速度

本文详细介绍了如何使用 ccache 工具缓存编译结果,以加速重复编译过程。包括 ccache 的安装步骤、配置环境变量、设置缓存大小、查看缓存信息及清除缓存的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.安装:
apt-get install ccache
# which ccache
/usr/local/bin/ccache
2.导出到环境变量
vi ~/.bashrc
#ccache
export USE_CCACHE=1
export CCACHE_DIR=/home/xx/tools/.ccache
3.设置ccache的大小
ccache -M 50G
4.查看ccache的信息
# ccache -s
cache directory                     /home/xx/tools/.ccache
cache hit (direct)                 79521
cache hit (preprocessed)            2589
cache miss                        127838
called for link                    29051
called for preprocessing            1687
compile failed                        65
preprocessor error                 31244
can't use precompiled header          84
couldn't find the compiler          3795
unsupported source language        26791
unsupported compiler option          127
no input file                       8108
files in cache                    373791
cache size                          40.4 Gbytes //编译android已经用了40.4个G了
max cache size                      50.0 Gbytes
5.清除所有
ccache -C
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值