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?
Best Answer
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, runmake -j
, which will build parallely using all CPU cores, ormake -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:
For C++ support, add the following:
Do note that, downgrading
libstdc++6
may cause breakage of some packages (for example,cmake
andfirefox
on my Ubuntu 18.10). Keeping multiple libstdc++'s is technically possible, but difficult to accomplish and surely not ideal.