gccmakefileubuntu-20.04gcc4.7

how to install older version of gcc -3 or gcc-4 in ubuntu 20


I'm trying to install an older version of gcc-4 on my Ubuntu system

CPU architecture

lscpu
Architecture:                    aarch64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
CPU(s):                          16
On-line CPU(s) list:             0-15
Thread(s) per core:              1
Core(s) per socket:              4
Socket(s):                       4
NUMA node(s):                    1
Vendor ID:                       ARM
Model:                           3
Model name:                      Cortex-A72
Stepping:                        r0p3
BogoMIPS:                        166.66
L1d cache:                       512 KiB
L1i cache:                       768 KiB
L2 cache:                        8 MiB
NUMA node0 CPU(s):               0-15
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Not affected
Vulnerability Spectre v1:        Mitigation; __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Branch predictor hardening
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid

and finally run the sudo make install got this error

    make[1]: Entering directory '/home/ubuntu/gcc-build'
/bin/bash ./gcc-4.8.0/mkinstalldirs /app/gcc/4.8.0 /app/gcc/4.8.0
/bin/bash: line 3: cd: ./fixincludes: No such file or directory
make[1]: *** [Makefile:3405: install-fixincludes] Error 1
make[1]: Leaving directory '/home/ubuntu/gcc-build'
make: *** [Makefile:2196: install] Error 2

how can I fix this issue


Solution

  • Hope you have updated package manager, in doubt you can run following commands (in the same order given, which should run without errors):

    sudo apt-get update
    sudo apt-get upgrade
    

    Then you need to ensure build-essential installed:

    sudo apt-get install build-essential
    

    After that you can install required version of gcc (example: gcc-4):

    sudo apt-get install gcc-4
    

    Now the part of selecting specific version of gcc:

    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4 4
    sudo update-alternatives --config gcc
    

    By this way you can switch between multiple versions of gcc too. The second command in the last step will give you a menu like option to select among available(installed) gcc versions to be set.