CentOS 7 install gcc 4.1.2

CentOS 7 install gcc 4.1.2

0. Reference

Compile gcc4.1.2 on centOS7.2

1. Install the required compilation

yum groupinstall "Development Tools"
yum install wget bzip2 texinfo glibc-devel glibc-static glibc binutils vim

Collect2: error: ld returned 1 exit status appears mostly because the compiled library is not installed, and glibc-devel must be installed.

2. Download the source code

wget http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2
tar jxvf gcc-4.1.2.tar.bz2

3. Modify the code

struct rt_sigframe {
    int sig;
    struct siginfo *pinfo;
    void *puc;
    struct siginfo info;
} *rt_ = context->cfa;

change to

struct rt_sigframe {
    int sig;
    siginfo_t *pinfo;
    void *puc;
    siginfo_t info;
    struct ucontext uc;
} *rt_ = context->cfa;

Otherwise there will be editing errors like the following

It has a compiling error when you build gcc4.1.2:
../gcc/config/i386/linux-unwind.h:138:17: error: field 'info' has incomplete type " 

4. Compile

cd gcc-4.1.2
./configure --prefix=/usr/local/gcc --enable-languages=c,c++
make

5. Replacing the existing gcc

cd /usr/bin/
mv gcc gcc-4.8.5 #4.8.5为现版本
mv g++ g++-4.8.5 #4.8.5为现版本
ln -s /usr/local/gcc-4.1.2/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc-4.1.2/bin/g++ /usr/bin/g++

Check that the gcc g++ version has been replaced

gcc -v

Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/usr/local/gcc-4.1.2 --enable-languages=c,c++
Thread model: posix
gcc version 4.1.2

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324980711&siteId=291194637