GCC
We need a modern C++17 capable compiler. Our minimum requirements are: GCC 7.5.0, Clang 5.0.2. This section will focus on building a GCC 9.4.0 compiler stack.
What version of GCC do we have?
gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If your version is less than 7.5.0, you will need to build a newer version. If your version is at or greater than 7.5.0, you have the option of skipping the GCC section.
cd $STACK_SRC
curl -L -O http://mirrors.concertpass.com/gcc/releases/gcc-9.4.0/gcc-9.4.0.tar.gz
tar -xf gcc-9.4.0.tar.gz -C .
Obtain GCC pre-reqs:
cd $STACK_SRC/gcc-9.4.0
./contrib/download_prerequisites
Configure, build and install GCC:
mkdir $STACK_SRC/gcc-build
cd $STACK_SRC/gcc-build
../gcc-9.4.0/configure --prefix=$PACKAGES_DIR/gcc-9.4.0 \
--disable-multilib \
--enable-languages=c,c++,fortran,jit \
--enable-checking=release \
--enable-host-shared \
--with-pic
make -j # (where # is the number of cores available)
make install
Any errors during configure/make will need to be investigated on your own. Every operating system I have come across has its own nuances of getting stuff built. Normally any issues are going to be solved by installing the necessary development libraries using your system package manager (apt-get, yum, zypper, etc). Hint: I would search the internet for 'how to build GCC 9.4.0 on (insert the name/version of your operating system here)'
In order to utilize our newly built GCC 9.4.0 compiler, we need to set some variables:
export PATH=$PACKAGES_DIR/gcc-9.4.0/bin:$PATH
export LD_LIBRARY_PATH=$PACKAGES_DIR/gcc-9.4.0/lib64:$PACKAGES_DIR/gcc-9.4.0/lib:$PACKAGES_DIR/gcc-9.4.0/lib/gcc/x86_64-pc-linux-gnu/9.4.0:$PACKAGES_DIR/gcc-9.4.0/libexec/gcc/x86_64-pc-linux-gnu/9.4.0:$LD_LIBRARY_PATH