Sysadmin:Software:GCC

From Earlham CS Department
Jump to navigation Jump to search

GCC stands for the GNU Compiler Collection. It includes front-ends, as well as libraries, for many languages including C, C++, Java, Fortran, Go, and Ada. It's completely open-source and usually comes as a standard on most operating systems. However, gcc is updated often, and the package manager repositories of some operating systems, particularly older ones, do not hold installs for newer versions. On our systems, we install multiple versions of gcc from source as an environment modules. Please read Environment Modules before proceeding to the install process.

Installing GCC from source

Download the source tarball from gnu.org. De-compress it into gcc-x.y.z. Make a new directory called gcc-x.y.z-build, and run the standard process to build from source.

Configure options

To configure it, we want to specify:

  • the prefix, usually /mounts/servername/software/gcc/x.y.z
  • the languages, typically c,c++,fortran, and go
  • enable threads
  • enable shared versions of libraries
  • disable multilib support

Read more about these here.

When you go to run make, you can speed up the (very very long) process somewhat by allocating more processors. Just use make -j $(nproc).

The command line is here:

../gcc-x.y.z/configure --prefix=/mounts/server/software/gcc/x.y.z --enable-languages=c,c++,fortran,go --enable-threads --enable-shared --disable-multilib
make -j $(nproc)
make install

You can combine these with nohup [command] &, which is a good idea because this process takes a long time and you don't want a SIGHUP (interrupted connection) to force you to start all over.

If you get interrupted mid-process make sure to run make distclean from within the gcc-x.y.z-build directory before starting over.