-
-
Save jeetsukumaran/5224956 to your computer and use it in GitHub Desktop.
#! /bin/bash | |
GCC_VERSION="5.2.0" | |
WORKDIR="$HOME/src/" | |
INSTALLDIR="/platform" | |
## NOTE: XCode must be installed (through App Store) and the following run to install command-line tools. | |
## THIS IS IMPORTANT! Among other things, it creates '/usr/include' and installs the system header files. | |
# xcode-select --install | |
# get the source code | |
cd $WORKDIR | |
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 | |
tar -xf gcc-${GCC_VERSION}.tar.bz2 | |
# download the prerequisites | |
cd gcc-${GCC_VERSION} | |
./contrib/download_prerequisites | |
# create the build directory | |
cd .. | |
mkdir gcc-build | |
cd gcc-build | |
# build | |
../gcc-${GCC_VERSION}/configure \ | |
--prefix=${INSTALLDIR} \ | |
--enable-shared \ | |
--enable-threads=posix \ | |
--enable-__cxa_atexit \ | |
--enable-clocale=gnu \ | |
--enable-languages=all \ | |
&& make \ | |
&& make install | |
# Notes | |
# | |
# --enable-shared --enable-threads=posix --enable-__cxa_atexit: | |
# These parameters are required to build the C++ libraries to published standards. | |
# | |
# --enable-clocale=gnu: | |
# This parameter is a failsafe for incomplete locale data. | |
# | |
# --disable-multilib: | |
# This parameter ensures that files are created for the specific | |
# architecture of your computer. | |
# This will disable building 32-bit support on 64-bit systems where the | |
# 32 bit version of libc is not installed and you do not want to go | |
# through the trouble of building it. Diagnosis: "Compiler build fails | |
# with fatal error: gnu/stubs-32.h: No such file or directory" | |
# | |
# --with-system-zlib: | |
# Uses the system zlib instead of the bundled one. zlib is used for | |
# compressing and uncompressing GCC's intermediate language in LTO (Link | |
# Time Optimization) object files. | |
# | |
# --enable-languages=all | |
# --enable-languages=c,c++,fortran,go,objc,obj-c++: | |
# This command identifies which languages to build. You may modify this | |
# command to remove undesired language |
[root@localhost /home/admin/gcc-6.3.0]# ./contrib/download_prerequisites
./contrib/download_prerequisites: line 37: wget: command not found
[root@localhost /home/admin/wget-1.19]# ./configure
When I try to install wget, I get the following error:
configure: configuring for GNU Wget 1.19
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking whether make supports nested variables... (cached) yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in /home/admin/test/wget-1.19': configure: error: no acceptable C compiler found in $PATH See
config.log' for more details
Thanks.
@jithinjk from the log it looks like you need to install "wget" as well as "gcc" on the machine.
Nice utility, but GCC has started using .tar.gz
now for releases instead of .tar.bz2
beginning with 6.4.0 so if the version number is changed (7.2.0 for example), the script will fail if the archive is not changed as well.
I followed the steps. However, I am stuck with an error related to -no-pie not being supported by the old g++ I was using to build this new one. Please help.
The configure command I used to build gcc 8.2:
../gcc_${GCC_VERSION}_src/configure --prefix=${INSTALLDIR} --enable-languages=c,c++ --disable-libquadmath --disable-libquadmath-support --disable-werror --disable-shared --disable-multilib --disable-lto --enable-default-pie
Details of my system and g++:
g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
They use .tar.gz
now instead of .tar.bz2
#! /bin/bash
GCC_VERSION="9.3.0"
WORKDIR="$HOME/src/"
INSTALLDIR="/platform"
## NOTE: XCode must be installed (through App Store) and the following run to install command-line tools.
## THIS IS IMPORTANT! Among other things, it creates '/usr/include' and installs the system header files.
# xcode-select --install
# get the source code
cd $WORKDIR
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz
tar -xvf gcc-${GCC_VERSION}.tar.gz
# download the prerequisites
cd gcc-${GCC_VERSION}
./contrib/download_prerequisites
# create the build directory
cd ..
mkdir gcc-build
cd gcc-build
# 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
# Notes
#
# --enable-shared --enable-threads=posix --enable-__cxa_atexit:
# These parameters are required to build the C++ libraries to published standards.
#
# --enable-clocale=gnu:
# This parameter is a failsafe for incomplete locale data.
#
# --disable-multilib:
# This parameter ensures that files are created for the specific
# architecture of your computer.
# This will disable building 32-bit support on 64-bit systems where the
# 32 bit version of libc is not installed and you do not want to go
# through the trouble of building it. Diagnosis: "Compiler build fails
# with fatal error: gnu/stubs-32.h: No such file or directory"
#
# --with-system-zlib:
# Uses the system zlib instead of the bundled one. zlib is used for
# compressing and uncompressing GCC's intermediate language in LTO (Link
# Time Optimization) object files.
#
# --enable-languages=all
# --enable-languages=c,c++,fortran,go,objc,obj-c++:
# This command identifies which languages to build. You may modify this
# command to remove undesired language
Hi jeetsukumaran
Does your script work on windows OS ?
Markus