Installing from Source Code

Synopsis

Most projects include the necessary files to automate compiling, and the two predominant configuration tools are autoconf and CMake. The general approach is to configure the project with an install location where you have write access and then perform the install steps.


GNU Autoconf

Projects that us Autoconf will include a “configure” script in the source files.  Most configure scripts accept --help to enumerate all options. You will use the --prefix=dir option  to specify a user writable directory for the install

./configure --prefix=$HOME/.local/

make

make install


Autoconf Example: samtools

export INSTALLDIR=~/.usr/local/samtools/1.21

mkdir -p $INSTALLDIR


wget https://github.com/samtools/samtools/releases/download/1.21/samtools-1.21.tar.bz2

tar -xjf samtools-1.21.tar.bz2

cd samtools-1.21


./configure --prefix=$INSTALLDIR

make -j 4

make install


CMake

Projects that utilize CMake will include a “CMakeLists.txt” file in the source files. You shoul load a CMake module to use an modern version of the system and the specify a writable location via the -DCMAKE_INSTALL_PREFIX=dir option:

module load CMake/3.27.6-GCCcore-13.2.0

mkdir build; cd build

cmake -DCMAKE_INSTALL_PREFIX=$HOME/.usr/local

make

make install


CMake Example: OpenCV 4.11.0

export INSTALLDIR=~/.usr/local/opencv/4.11.0

mkdir -p $INSTALLDIR


wget https://github.com/opencv/opencv/archive/refs/tags/4.11.0.tar.gz

tar -xzf 4.11.0.tar.gz

cd opencv-4.11.0


mkdir build; cd build

cmake -DCMAKE_INSTALL_PREFIX=$INSTALLDIR

make

make install