Skip to content

Compiling Software

Overview

On the clusters you will frequently need to build software from source. This guide shows how to use the GNU Build System (Autotools), plain make, and cmake to configure, compile, and install programs in your user space.

Autotools (GNU Build System)

The classic GNU Build System is based on two key pieces:

  • a configure script that adapts the build to the current machine
  • one or more Makefiles that describe how to build and install the software with make.

In practice, building many Autotools-based packages on the cluster boils down to the standardized three-step sequence:

./configure --prefix=$HOME/software/<program_name>
make
make install

This is exactly the pattern described in the GNU Build System documentation: configure probes the system and writes Makefiles with the right compiler, flags and paths, and each run of make then checks what needs to be rebuilt before executing the corresponding rules.

Some tips when using Autotools on the cluster:

  • Out-of-tree builds: When possible, build in a separate directory to keep the source tree clean.
  • Prefix per user: Keep --prefix inside your home directory (for example $HOME/software/mytool) so you do not need administrator privileges.
  • Re-configuring: If you change compilers or important environment variables, re-run ./configure so the generated Makefiles match the new environment.

Make

make is the core tool that executes the build rules described in a Makefile. On the clusters you will see it both as part of the GNU Build System (./configure && make && make install) and in simpler projects that ship only a hand-written Makefile.

  1. Compiling a Project with Make: With a suitable Makefile in the project directory, start the compilation with:

    make
    
  2. Customizing the Build: You can pass variables on the command line to choose compilers or optimization flags, for example:

    make CC=gcc CFLAGS="-O2"
    
  3. Installing (when supported): Some Makefiles also provide an install target similar to Autotools. In those cases you might see:

    make install
    

Always check the project’s documentation or run make help to see which targets are available.

CMake

  1. Loading CMake: To use CMake on the cluster, first load the corresponding module:

    module load cmake
    
  2. Configuring and Compiling a Project with CMake:

  3. Create a build directory:

    mkdir build
    cd build
    
  4. Run CMake to configure the project, specifying the source directory:

    cmake ../source_directory
    
  5. After configuration, compile the project with:

    make
    

Problems and Support

If you encounter issues when using Make or CMake to compile software, please refer to our support page for assistance.