由于Linux上的三首源代码安装软件都需要GCC编译,因此Linux上有预安装的GCC,但出于稳定性和兼容性的考虑,其版本都是低稳定版本,但在安装最新软件时针对非根用户的解决方案是在自己的目录中安装所需版本的GCC。
我如何证明我需要升级你的GCC版本?
如果在编译zjddp安装软件make时显示以下错误,则需要升级:
1
2g-STD=c11-pedantic-wall-wextra-CCCS sequence.CPP-occssequence.o
C1 plus : error : unrecognizedcommandlineoption '-STD=c11 '
-std=c 0x受g -4.4支持,-std=c 11是g -4.7或更高版本。
GCC -v将查看当前系统的GCC版本,以确定GCC版本问题是否导致错误。
GCC安装
因为在安装gcc之前依赖于三个软件包: gmp、mpc和mpfr,所以首先要安装这三个软件包。 这三个软件包可以在以下infrastructure目录中下载: gcc源包在发行版中下载。 这里gcc下载的版本是gcc-4.8.5。
由于这三个软件包之间存在依赖关系,因此必须按以下顺序依次安装:
gmp安装1
2
3
4
5
6
7
8
9
10
11$tar -jxvf gmp-4.3.2.tar.bz2
$cd gmp-4.3.2
$./configure-- prefix=/home/software/opt/GMP-4.3.2/# GMP安装路径
$make
$make check #你可以放弃这一步
$make install
MFR安装1
2
3
4
5
6
7
8
9
10
11tar -jxvf mpfr-2.4.2.tar.bz2
$cd mpfr-2.4.2
$./configure---prefix=/home/software/opt/mpfr-2.4.2//-with-GMP=/home/software/opt/GMP
$make
$make check #你可以放弃这一步
$make install
mpc安装1
2
3
4
5
6
7
8
9
10
11$tar -zxvf mpc-0.8.1.tar.gz
$cd mpc-0.8。
$./configure---prefix=/home/software/opt/MPC-0.8.1//-with-GMP=/home/software/opt/GMP
$make
$make check #你可以放弃这一步
$make install
更改~/.bashrc文件
安装上述三个依赖软件包后,设置环境变量$LD_LIBRARY_PATH。 也就是说,在bashrc文件中添加以下内容:
由于系统的LD_LIBRARY_PATH有两个相邻的冒号,编译gcc将不起作用,因此请先自行重新定义此变量,然后将上面的三个软件包添加到该变量中
1
2
3
4
5导出LD _ library _ path=/public/software/MPI/open MPI/1.6.5/Intel/lib 3360/opt/GridView/PBS/diss public/software/compiler/Intel/composer _ xx lic lib 643360/usr/local/lib :/usr/local/otpserver/depender
导出LD _ library _ path=~/opt/GMP-4.3.2/lib/:~/opt/mpfr-2.4.2/lib/:~/opt/MPC -。
导出库_ path=$ LD _ library _ path
不然会碰到错误 configure: error: cannot compute suffix of object files: cannot compile
gcc安装
完成依赖包的安装和环境设置后就可以开始GCC的安装了
1
2
3
4
5
6
7
8
9$tar -jxvf gcc-4.8.5.tar.bz2
$cd gcc-4.8.5
$./configure --prefix=/home/software/opt/gcc-4.8.5/ --enable-threads=posix --disable-checking --disable-multilib --with-mpc=/home/software/opt/mpc-0.8.1/ --with-gmp=/home/software/opt/gmp-4.3.2/ --with-mpfr=/home/software/opt/mpfr-2.4.2/
make -j 10 #类似于使用10个线程编译,速度要快很多,此过程需要较长时间,中间不要间断。
make install
更改~/.bashrc文件
在文件中加入一下两句将gcc加入到环境变量中。
1
2
3export PATH=/home/software/opt/gcc-4.8.5/lcddfk/:$PATH
export LD_LIBRARY_PATH=/home/software/opt/gcc-4.8.5/lib/:~/opt/gcc-4.8.5/lib64/:$LD_LIBRARY_PATH
安装过程报错暨解决办法
Linux安装任何软件切记 路劲 路劲 路劲 要的事说3编!
路劲报错主要类型如下:
1)路劲缺失
解决:export PATH=”$PATH:/home/lcddfk/amos-3.1.0/lcddfk”相应缺失路径到.bashrc文件。
2)当前软件安装路径存在,如下面报错[configure-stage2-gcc] Error 1 。
3)意外路径存在于环境变量中,如下面blasr安装编译报错。
报错[configure-stage2-gcc] Error 11
2
3
4
5
6contains current directory
configure: error:
*** LIBRARY_PATH shouldn't contain the current directory when
*** building gcc. Please change the environment variable
*** and run configure again.
make[2]: *** [configure-stage2-gcc] Error 1
1)根据提示看出是LIBRARY_PATH环境变量不应该包含有当前安装GCC的路径,即我想要安装gcc路径为/honm/software/gcc-4.8.5/,那个echo $LIBRARY_PATH就不应该包含此路径。
2)若echo $LIBRARY_PATH输出结果为/usr/lib/x86_64-linux-gnu/:(注意结尾冒号),则同样会报错,解决办法就是去掉冒号/usr/lib/x86_64-linux-gnu/。
3)解决办法unset LIBRARY_PATH; ./configure -v。来源于http://stackoverflow.com/questions/8565695/error-compiling-gcc-4-6-2-under-ubuntu-11-10
报错[stage1-bubble] Error 21
2
3make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/np/linac/belloni/programs/gcc/gcc-build'
make: *** [all] Error 2
解决:主要由Error 1 报错引起的,在第一个报错解决后此错误消失。
后续编译其他软件报错
安装blasr报错如下:1
2
3
4
5
6
7
8g++ -std=c++11 -pedantic -Wall -Wextra -c CCSSequence.cpp -o CCSSequence.o
/public/home/zpxu/lcddfk/gcc-4.8.5/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5/cc1plus: error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory
make[3]: *** [CCSSequence.o] Error 1
make[3]: Leaving directory `/public/home/zpxu/lcddfk/blasr_install/blasr/libcpp/pbdata'
make[2]: *** [libpbdata] Error 2
make[2]: Leaving directory `/public/home/zpxu/lcddfk/blasr_install/blasr/libcpp'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/public/home/zpxu/lcddfk/blasr_install/blasr/libcpp'
报错原因在于blasr安装相关路径已经存在于系统环境变量中,注释掉.bashrc中相应路径。
make install后报错1/lcddfk/llvm-tblgen: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /lcddfk/llvm-tblgen)
解决办法:
I found the libstdc++.so.6.0.18 at the place where I complied gcc 4.8.1
Then I do like this
1
2
3
4
5
6cp ~/objdir/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.18 /usr/lib64/
rm /usr/lib64/libstdc++.so.6
ln -s libstdc++.so.6.0.18 libstdc++.so.6
problem solved.
GCC延伸阅读
Linux下gcc生成和使用静态库和动态库详解
Linux添加环境变量与GCC编译器添加INCLUDE与LIB环境变量
贡献来源:
http://favoorr.github.io/centos6.6-build-gcc5.2-from-source/
http://stackoverflow.com/questions/5216399/usr-lib-libstdc-so-6-version-glibcxx-3-4-15-not-found