阿里云默认的gcc是4.4.7版本,不支持C++11,需要手动升级。
1. wget http://gcc.skazkaforyou.com/releases/gcc-4.8.2/gcc-4.8.2.tar.gz
2. tar zxvf gcc-4.8.2.tar.gz
3. ./contrib/download_prerequisites
4. mkdir build
5. cd build
6. ../configure –prefix=/usr
7. make && make install
此时会报错
build/genattrtab ../.././gcc/config/i386/i386.md insn-conditions.md \
-Atmp-attrtab.c -Dtmp-dfatab.c -Ltmp-latencytab.c
make[3]: *** [s-attrtab] Killed
make[3]: Leaving directory `/usr/src/gcc-4.9.2/host-x86_64-unknown-linux-gnu/gcc’
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/usr/src/gcc-4.9.2′
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/usr/src/gcc-4.9.2′
make: *** [all] Error 2
发现这是阿里云独有的共性错。。因为没有swap分区。。
首先调整swap分区为1G
1. dd if=/dev/zero of=/tmp/myswap bs=32k count=32768
2. mkswap /tmp/myswap
3. swapon /tmp/myswap
此时free -m可以看到swap为1g
4. sudo sysctl vm.swappiness=10
64位系统又会报错
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
需要yum -y install glibc-devel.i686 glibc-devel
参考:
http://my.oschina.net/u/1465953/blog/209029?fromerr=kbNcnjMH
http://bbs.csdn.net/topics/390817656
http://blog.csdn.net/tangyi2008/article/details/42099427
http://www.educity.cn/wenda/566626.html