[心得]给CentOS6.5升级开发工具gcc

一、背景

在给centos6.5配置vim插件管理工具vundle时,首先遇到的问题是当时升级的python2.7是按静态库编译的,解决方法是重新用动态库的方法编译了python2.7:
具体参数忘了,是用google查到的解决方法。
当动态.SO库文件准备好后,系统总是报告找不到动态库。
百思不得解,最后是隔了几天重启虚拟机python这个动态库才生效。。汗

重新编译YouCompleteMe:

./install.sh

又遇到这个gcc版本太低的问题。

二、具体解决过程
系统自带版本是4.4.7版本太旧,无法使用g++ -std=c++11 命令来编译 C++11、无法使用Vim的很多插件(YouCompleteMe等)。

yum update gcc无法获取到gcc的新源。
参考这个方法:http://www.wengweitao.com/centos-sheng-ji-gcc-he-g-de-fang-fa.html

devtools-1.1有些老了,我用的是devtools-2
可以到这个目录找找你感兴趣的软件包:
https://people.centos.org/tru/

cd /etc/yum.repos.d
wget https://people.centos.org/tru/devtools-2/devtools-2.repo

然后是安装软件:

yum --enablerepo=testing-devtools-2-centos-6 install devtoolset-2-gcc -y devtoolset-2-gcc-c++ -y

实际安装到的路径是:

ll /opt/rh/devtoolset-2/root/usr/bin/

把它们全部链接到/usr/local/bin下:

$:ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin
$:hash -r

$:g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

再更新,发现4.8.2太新了,YouCompleteMe最新的代码遇到兼容性问题,重新下载devtools-1.1试试。

$:cd /etc/yum.repos.d
$:wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo 
$:yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++ -y -y

$:ll /opt/centos/devtoolset-1.1/root/usr/bin/

把它们全部链接到/usr/local/bin下:

$:ln -s /opt/centos/devtoolset-1.1/root/usr/bin/* /usr/local/bin/
hash -r

如果遇到报错,就把报错的/usr/localbin/下对应的软链接文件全部删掉。

大功告成!

你可能感兴趣的:(技术笔记)