1

I have tried several methods for build and install gcc-5.4.0 on my PC;

I ran this code:

GCC_VERSION="5.4.0"
WORKDIR="$HOME/src/"
INSTALLDIR="/platform"

cd $WORKDIR
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2
tar -xf gcc-${GCC_VERSION}.tar.bz2

cd gcc-${GCC_VERSION}
./contrib/download_prerequisites

cd ..
mkdir gcc-build
cd gcc-build

../gcc-${GCC_VERSION}/configure                      \
    --prefix=${INSTALLDIR}                           \
    --enable-shared                                  \
    --enable-threads=posix                           \
    --enable-__cxa_atexit                            \
    --enable-clocale=gnu                             \
    --enable-languages=all                           \
&& make \
&& make install

which did not work; telling me that I should disable multi-lib.

I did it using this code:

GCC_VERSION="5.4.0"
WORKDIR="$HOME/src/"
INSTALLDIR="/platform"

cd $WORKDIR
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2
tar -xf gcc-${GCC_VERSION}.tar.bz2

cd gcc-${GCC_VERSION}
./contrib/download_prerequisites

cd ..
mkdir gcc-build
cd gcc-build

../gcc-${GCC_VERSION}/configure                      \
    --prefix=${INSTALLDIR}                           \
    --enable-shared                                  \
    --enable-threads=posix                           \
    --enable-__cxa_atexit                            \
    --enable-clocale=gnu                             \
    --enable-languages=all                           \
    --disable-multilib                               \
&& make \
&& make install

which was running for almost half an hour and made a directory as big as 1 GB. So I doubted the source file and interrupted it.

Then I tried downloading gcc-5.4.0 from another source.

Compiled with the following command:

GCC_VERSION="5.4.0"
WORKDIR="$HOME/src/"
INSTALLDIR="/platform"

cd $WORKDIR
wget http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2
tar -xf gcc-${GCC_VERSION}.tar.bz2

cd gcc-${GCC_VERSION}
./contrib/download_prerequisites

cd ..
mkdir gcc-build
cd gcc-build

../gcc-${GCC_VERSION}/configure                      \
    --prefix=${INSTALLDIR}                           \
    --disable-multilib                               \
    --enable-shared                                  \
    --enable-threads=posix                           \
    --enable-__cxa_atexit                            \
    --enable-clocale=gnu                             \
    --enable-languages=all                           \
&& make \
&& make install

Again I got an error, do you know any direct way that I can do that?

  • What is your Ubuntu version? It is unclear why do you not want to install the gcc-5 package from official repository? Do you plan to use it as cross-compiler? – N0rbert Jan 15 '19 at 19:10
  • My Ubuntu is 18.04 for which gcc 5.4 is not available through apt. – Mone Jan 16 '19 at 19:39
  • Did you check this link? – singrium Jun 16 '19 at 12:01
0

... which was running for almost half an hour and made a directory as big as 1 GB. So I doubted the source file and interrupted it.

It's possible that you're on the right track, and rushed into stopping the build prematurely. Depending on the strength of your machine, 30 minutes doesn't sound unreasonable time for building GCC. Most importantly, you're building using make, which means that source files are compiled serially, one at a time, which is make's default. For speeding up the build significantly, run make -j, which will build parallely using all CPU cores, or make -j4 for running 4 parallel compile jobs, for example.

As for build size, I suspect that by default, GCC builds in Debug mode, which would explain the bloated build folder (for comparison, LLVM debug build could easily stack up to > 4GB).

However, if you don't have to build your own copy of GCC from source, you could use pre-built 5.4 packages available on Launchpad.

For GCC (C only), grab the .deb files and install them in order:

mkdir ~/Downloads/gcc-5.4-deb && cd ~/Downloads/gcc-5.4-deb

wget http://launchpadlibrarian.net/375474546/gcc-5-base_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://launchpadlibrarian.net/375474798/libasan2_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://launchpadlibrarian.net/375474828/libmpx0_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://launchpadlibrarian.net/375474805/libgcc-5-dev_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://launchpadlibrarian.net/375474748/cpp-5_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://launchpadlibrarian.net/375474755/gcc-5_5.4.0-6ubuntu1~16.04.10_amd64.deb

sudo dpkg -i gcc-5-base_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i libasan2_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i libmpx0_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i libgcc-5-dev_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i cpp-5_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i gcc-5_5.4.0-6ubuntu1~16.04.10_amd64.deb

For C++ support, add the following:

wget http://launchpadlibrarian.net/375474836/libstdc++6_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://launchpadlibrarian.net/375474834/libstdc++-5-dev_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://launchpadlibrarian.net/375474751/g++-5_5.4.0-6ubuntu1~16.04.10_amd64.deb

sudo dpkg -i libstdc++6_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i libstdc++-5-dev_5.4.0-6ubuntu1~16.04.10_amd64.deb
sudo dpkg -i g++-5_5.4.0-6ubuntu1~16.04.10_amd64.deb

Do note that, downgrading libstdc++6 may cause breakage of some packages (for example, cmake and firefox on my Ubuntu 18.10). Keeping multiple libstdc++'s is technically possible, but difficult to accomplish and surely not ideal.

0

I had to install the following packages in addition to what valiano mentioned:

wget http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libcilkrts5_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libubsan0_5.4.0-6ubuntu1~16.04.10_amd64.deb
wget http://cz.archive.ubuntu.com/ubuntu/pool/main/i/isl/libisl15_0.16.1-1_amd64.deb
wget http://cz.archive.ubuntu.com/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb
0

The difference between gcc 5.5.0 and gcc 5.4 is so minimal that maybe you'll never know the difference. I have gcc 5.5.0 (gcc-5) installed in Ubuntu 18.04, and I'm not aware of any functionality that's missing because I don't have gcc 5.4 installed too.

You don't need to build gcc-5 in Ubuntu 18.04; instead it can be installed with apt. To install gcc 5.5.0 in Ubuntu 18.04 open the terminal and type:

sudo apt install gcc-5  

Multiple versions of gcc can be installed alongside each other in Ubuntu 18.04, for example gcc-5 and gcc-8. You can change the default gcc version by using the update-alternatives command to determine which actual file is referenced by a generic name, for example which actual file is referenced by gcc. For more information see the answers to this question: How to change the default GCC compiler in Ubuntu?.

0

When the package is already half a gigabyte, it's a gigabyte when unpacking the sources.

But switch --disable-multilib is non-sense when building a C/C++ compiler.

The error message disable multi-lib means: cannot build 32-bit assembly, because missing the 32-bit glibc library. I've ran into this issue yesterday and needed to install yum install glibc-devel.i686. On Ubuntu Linux, this should be apt-get install glibc-dev.i386 or probably libc6-dev-i386. Just manually provide the packages it depends upon, or fix that (probably outdated) ./contrib/download_prerequisites shell script to include this package.

Else you'll end up with a compiler that cannot build for x86, but only x86_64.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.