Installation {#install}

October 9, 2025 ยท View on GitHub

Requirements

Linux and Unix-like Operating Systems

The following tools and libraries are required for installing MEPACK on Linux or Unix-like operating systems:

  • A Fortran compiler supporting Fortran 95/2003, e.g. GNU Fortran, Intel ifort, IBM XLF, ...
  • A C99 compiler, e.g. GNU GCC, Intel icc, IBM XLC, ...
  • (optional) A C++17 compiler for MATLAB/GNU Octave interfaces
  • CMake 3.15 or newer. If Intel's oneAPI icx and ifx are used, CMake>=3.20 is required.
  • BLAS and LAPACK, at least version 3.4.2
  • (optional) HDF5, at least version 1.8.5 (only for tests and examples)
  • (optional) doxygen, at least version 1.8.16 with dot, if the HTML documentation is required
  • (optional) MATLAB, at least 2018a, for building the MATLAB interface
  • (optional) GNU Octave, at least version 4.4, for building the GNU Octave interface
  • (optional) lcov and gcov for building the tests with code coverage

The following compilers are known to be unusable due to compiler bugs:

  • AMD AOCC 3.x and 4.0 (Compiler Crash)
  • Intel ICC/IFort Classic 2021 (OpenMP failures)
  • Intel ICX/IFX 2021.x, 2022.x (OpenMP failures)

If the BLAS / LAPACK library does not provide the full interface, i.e. some routines are not implemented or available for the user, MEPACK builds the required but missing routines from reference LAPACK and includes them in MEPACK. This is the if IBM ESSL is used as BLAS library.

Microsoft Windows

MEPACK can be built on MS Windows using the MSYS2 (https://www.msys2.org/) environemnt in combination with the MingW64(gcc) compiler. We support both, the MSVCRT and the UCRT runtime environment. If you are plan to use MSVCRT set

export MINGWPREFIX=mingw-w64-x86_64

In case of the UCRT runtime set

export MINGWPREFIX=mingw-w64-ucrt-x86_64

Afterwards, the required packages can be installed using

pacman -S ${MINGWPREFIX}-gcc ${MINGWPREFIX}-gcc-fortran \
          ${MINGWPREFIX}-cmake ${MINGWPREFIX}-ninja \
          ${MINGWPREFIX}-openblas ${MINGWPREFIX}-openblas64 \
          ${MINGWPREFIX}-hdf5

Installation

The source code is configured using CMake. An out-of-source build is preferred. Typically, this is done by

cmake -S . -B build-dir  <OtherCMakeOptions>
make -C build-dir
make -C build-dir install

The following options can be added to CMake to configure MEPACK properly, for MATLAB/GNU Octave specific options, see below:

OptionDescriptionDefault
-DDEBUG=ON/OFFEnable building the library in debug modeOFF
-DBUILD_STATIC=ON/OFFEnable building the static libraries.OFF
-DBUILD_DYNAMIC=ON/OFFEnable building the dynamic/shared libraries.ON
-DCOVERAGE=ON/OFFEnable the creation of code coverage filesOFF
-DCMAKE_INSTALL_PREFIX=PREFIXInstallation prefix/usr/local
-DBLA_VENDOR=VENDOR_NAMESet the BLAS library to use.Generic
See FindBLAS.cmake for details
-DHOSTOPT=ON/OFFEnable host-specific optimizationsOFF
-DLTO=ON/OFFEnable Link Time OptimizationOFF
-DVALGRIND_SUPPRESSIONS=PATHSet a suppressions file for valgrindempty
-DINTEGER8=ON/OFFBuild with 64-bit integers and 64 bit BLASOFF
-DFORTRAN_BOUND_CHECK=ON/OFFCheck the array bounds at runtime (slow)OFF
-DFORTRAN_SANITIZE=ON/OFFCheck the memory accesses at runtime (slow)OFF
-DDOC=ON/OFFBuild the documentationOFF
-DMATLAB=ON/OFFEnable MATLAB / Octave interface buildingOFF
-DEXAMPLES=ON/OFFBuild the tests and examplesON
-DMEPACK_LUA_CONFIG=PATHPath for an alternative configuration fileempty
-DRECSY=PATHPath to a precompiled library containingempty
the RECSY library.empty
-DGL705=PATHPath to a precompiled library containingempty
the code from Algorithm 705 as library.empty
-DCMAKE_INSTALL_MODULEDIR=PATHCustom destination directory for Fortran/usr/include/mepack/
modules.

The examples/tests are only built if BUILD_DYNAMIC=ON, otherwise they can not be used.

The test suite is executed by calling

make -C build-dir test

If valgrind was found during the configuration procedure, all tets can be executed with the help of valgrind by executing:

cd build-dir
ctest -D NightlyMemoryCheck

The documentation is built in build-dir/doc by calling:

make -C build-dir doc

MATLAB/Octave Interface

The MATLAB/Octave interface is built if -DMATLAB=ON is set during configuration. The build process can be adjusted using the following CMake options:

OptionDescriptionDefault
-DMEXOCT_MATLAB_DOC=ON/OFFExtract the help texts for MATLAB from Mex-Files,OFF
-DMEXOCT_MATLAB=ON/OFFSearch for MATLABON
-DMEXOCT_OCTAVE=ON/OFFSearch for OctaveON
-DMEXOCT_MATLAB_ROOT=PATHPath of the MATLAB installationempty
-DMEXOCT_OCTAVE_CONFIG=PATHFull path of the octave-config toolempty
-DMEXOCT_LINK_STATIC=ON/OFFStatic linking of MEPACK to the MEX/OCT filesOFF
-DMEXOCT_SKIP_RPATH=1/0Skip the RPATH setting in MEX/OCT files0

After compiling, the build directory contains a matlab/matlab folder including the mex files to be used with MATLAB and a matlab/octave folder, which contains the octfiles for GNU Octave. Furthermore, a distribution archive

mepack-<MEPACK_VERSION>-matlab-<MATLAB_VERSION>-<ARCH>-dist.{tar.gz,zip}

for MATLAB and

mepack-<MEPACK_VERSION>-octave-<OCTAVE_VERSION>-<ARCH>-dist.tar.gz

for GNU Octave is created in the root of the build directory. These files can be used to ship the compiled MEX/OCT files to othersystems.

The test suite is also added to the test target of the main makefile. In this way

make -C build-dir test

will also test the MATLAB/Octave interface. In order to test the MATLAB/Octave interface separately run

cd build-dir/matlab
make test

By default (MEXOCT_SKIP_RPATH=0) the MEX and OCT files have set its RPATH to the $ORIGIN and thus will search for the libmepack.so file in the current directory. In this case, the libmepack.so is copied to the matlab or octave directory. In this case, the libmepack.so file will also be added to the distribution archives. If MEXOCT_LINK_STATIC is enabled, no RPATH is required since MEPACK is statically linked to the MEX/OCT files, resulting in larger files. The libmepack.so file is not part of the distribution file in this case.

Attention: The MATLAB part of the interface requires -DINTEGER8=ON in most cases, since MATLAB uses 64-bit integers everywhere. In the case of GNU Octave the setting -DINTEGER8=OFF is required in most cases, since Octave uses 64-bit integers internally, but uses BLAS/LAPACK/other Fortran codes with 32-bit integers.

Attention: Enable the static linkage with MEXOCT_LINK_STATIC also requires to build the static library with BUILD_STATIC=ON.

Warning: The MATLAB interface is implemented using C++ template meta programming and thus the compiling the code leads to a huge memory consumption. If MEPACK is build in parallel, e.g. make -j 4, this can crash your computer. For reason the MATLAB interface should be compiled with one job per 8 GB of free memory. If your are not sure if this is fulfilled, consider compiling the code with only one job, i.e. make -j 1.

MATLAB Interface on Microsoft Windows

Since MATLAB and its shipped libraries behave slightly different compared to the Linux/Unix world, building the MEPACK MATLAB interface under Microsoft Windows requires a special build configuration. Using MEPACK the MSYS2 MingW64 environment using either the MSVCRT or the UCRT runtime is required. Therefor, the requirements from above are required to installed beforehand.

The MATLAB interface is built from the MINGW64 command line using:

cmake -DLTO=OFF -DINTEGER8=ON -DBUILD_STATIC=ON -DBUILD_DYNAMIC=OFF \
      -DMATLAB=ON -DMEXOCT_OCTAVE=OFF -DMEXOCT_LINK_STATIC=ON \
      -DCMAKE_Fortran_FLAGS="-fno-underscoring" -DMEXOCT_MATLAB_DOC=OFF \
      -S . -B build-matlab
cmake --build build-matlab

Afterwards, the distribution can be found as zip-file in the build-dir directory.

Building for GNU Octave on Windows is not possible at the moment.

RECSY and Algorithm 705

The RECSY library and the reference implementation of Algorithm 705 cannot be shipped due to unclear licenses. If you want to compile the examples with support for these codes, you have to provide a shared or static library containing the codes yourself. Perferably, RECSY and Algorithm 705 should be compiled as static library with the -fPIC flag set during compilation. Then they can be enabled in the during the build via

 cmake ....... -DRECSY=/path/to/librecsy.a -DGL705=/path/to/libgl705.a