因業務需要安裝7.4高版本gcc時報錯:
configure: error: in `/usr/local/src/gcc-7.4.0/build/gcc':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
make[3]: Leaving directory `/usr/local/src/gcc-7.4.0/build/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/usr/local/src/gcc-7.4.0/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/usr/local/src/gcc-7.4.0/build'
make: *** [all] Error 2
解決:
yum install -y glibc-headers gcc-c++ #參考鏈接https://www.cnblogs.com/niocai/archive/2011/11/04/2236458.html
知識點擴展:
在網上尋找解決方案時碰到一些人說是因內存不足需要添加swap分區來解決,未實際驗證,這里給出添加swap分區的方法
添加命令
SWAP=/tmp/swap
dd if=/dev/zero of=$SWAP bs=1M count=500 #500為swap分區大小
mkswap $SWAP
swapon $SWAP #啟用swap
當發現swap分區不夠用,想繼續加大時,需要先關閉正在使用的swap分區,然后重新分配
swapoff /tmp/swap 或者swapoff -a這兩個命令均可關閉swap分區
注意:如果不關閉現有swap分區但想繼續擴容swap分區時,當執行dd命令時會報如下錯:
dd: failed to open ‘/tmp/swap’: Text file busy
另外根據需要可以將swap寫入/etc/fstab使其永久生效
/tmp/swap swap swap defaults 0 0