ALPS Installation on Mac/Linux from Sources
For most cases, it is preferred to install ALPS from Binaries. However, for more user control and configuration, installing from Sources could be a better approach.
Install Required Dependencies
ALPS relies on a handful of external libraries. Choose one MPI and one BLAS provider that fit your system:
| Dependency | Minimum version | Packages |
|---|---|---|
| HDF5 | 1.10.0 | libhdf5-dev |
| CMake | 3.18 | cmake |
| C++ Compiler | GCC 10.5.0 & Clang 13.0.1 | build-essential |
| Boost | 1.76 (1.87 required to build ALPS Python bindings against NumPy ≥ 2.0) | see below |
| MPI | OpenMPI 4.0 or MPICH 4.0 | libopenmpi-dev / libmpich-dev |
| BLAS | 0.3 | libopenblas-dev |
| Python | 3.9 | python.org |
Ubuntu / Debian / WSL
$ sudo apt update
$ sudo apt install build-essential cmake \
libhdf5-dev \
libopenblas-dev \
libopenmpi-dev openmpi-bin # or: libmpich-dev mpich
# install Python libs:
$ pip install numpy scipy # python libraries
# or
$ python3 -m pip install numpy scipyDo not install Boost via
apt. ALPS must compile Boost from source for two reasons:
- Custom compiler flags — ALPS requires
-DBOOST_NO_AUTO_PTRand-DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REFfor C++17/20 compatibility; thelibboost-devpackages do not set these, causing link errors.- Python-ABI match — the
Boost.Pythoncomponent must be compiled against the exact Python interpreter that ALPS will use. Pre-built packages target the system Python and will silently mismatch if you use a different one.CMake handles both automatically: it downloads and compiles Boost 1.87 during configuration (requires internet access). See the offline alternative in the build step below if needed.
macOS (via Homebrew)
$ brew update
$ brew install cmake hdf5 \
openblas open-mpi # or: mpich
# install Python libs:
$ pip3 install numpy scipyDo not install Boost via Homebrew. ALPS must compile Boost from source for two reasons:
- Custom compiler flags — ALPS requires
-DBOOST_NO_AUTO_PTRand-DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REFfor C++17/20 compatibility; the Homebrewboostformula does not set these, causing link errors.- Python-ABI match — the
Boost.Pythoncomponent must be compiled against the exact Python interpreter that ALPS will use. The Homebrew Boost targets Homebrew’s own Python and will silently mismatch any other interpreter.CMake handles both automatically: if
Boost_SRC_DIRis not set, it downloads and compiles Boost 1.87 during configuration (requires internet access). To build offline or reuse a previously extracted archive, download it manually first:$ curl -LO https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz $ tar -xzf boost_1_87_0.tar.gz
macOS (via MacPorts)
$ sudo port selfupdate
$ sudo port install cmake \
hdf5 \
OpenBLAS \
openmpi-clang20 # see note below about choosing a variant
$ sudo port select --set mpi openmpi-clang20-fortran
# install Python libs:
$ pip3 install numpy scipyChoosing an OpenMPI variant: MacPorts ships a separate port for each compiler version, named
openmpi-<compiler><version>(e.g.openmpi-clang20,openmpi-gcc15). Theclang20variant shown above matches the LLVM Clang 20 port and works alongside Apple’s Xcode clang. If you use a different compiler, install the matching variant and adjust theport selectcommand accordingly.The
port selectstep is required: without it, the barempirun,mpicc, andmpicxxwrappers that CMake looks for will not exist.
Do not install Boost via MacPorts. ALPS must compile Boost from source for two reasons:
- Custom compiler flags — ALPS requires
-DBOOST_NO_AUTO_PTRand-DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REFfor C++17/20 compatibility; the MacPortsboostports do not set these, causing link errors.- Python-ABI match — the
Boost.Pythoncomponent must be compiled against the exact Python interpreter that ALPS will use. MacPorts Boost targets MacPorts’ own Python and will silently mismatch any other interpreter.CMake handles both automatically: if
Boost_SRC_DIRis not set, it downloads and compiles Boost 1.87 during configuration (requires internet access). To build offline or reuse a previously extracted archive, download it manually first:$ curl -LO https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz $ tar -xzf boost_1_87_0.tar.gz
Verify Dependencies
$ gcc -v # must be >= 10.5.0
$ cmake --version # must be >= 3.18
$ mpirun --version # OpenMPI 4.0 or MPICH 4
$ python3 --version # must be >= 3.9
$ python3 -c "import numpy, scipy; print('numpy', numpy.__version__, 'scipy', scipy.__version__)"macOS — which Python will CMake use? CMake on macOS searches Apple’s framework paths before
$PATH, so it may silently select the Xcode-bundled Python 3.9 even if you have a newer Python installed via Homebrew or MacPorts. Duringcmakeconfiguration, look for a line like:-- Found Python: /path/to/python (found version "X.Y.Z")If the path or version is not what you expect, pin it explicitly by adding
-DPython3_EXECUTABLE=/path/to/your/python3to yourcmakecommand. Typical paths are/opt/homebrew/bin/python3(Homebrew) or/opt/local/bin/python3(MacPorts). Make surenumpyandscipyare installed for whichever Python CMake will use.
Download and Build
We can now proceed to download and build the ALPS library.
In the snippet below, replace </path/to/install/dir> with the directory where you want ALPS installed.
Before you run these commands, note two expected pauses:
cmakeconfiguration (~1–3 min): CMake silently downloads Boost 1.87 (~130 MB) during configuration. The terminal will produce no output for a minute or two while the download completes — this is normal, do not interrupt it.cmake --build(5–20 min): Compiling ALPS and Boost from source takes several minutes even with all CPU cores. The terminal will be busy printing compiler lines throughout — also normal.
$ git clone https://github.com/alpsim/ALPS alps-src
$ cmake -S alps-src -B alps-build \
-DCMAKE_INSTALL_PREFIX=</path/to/install/dir> \
-DCMAKE_CXX_FLAGS="-DBOOST_NO_AUTO_PTR \
-DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REF"
# ^ Boost (~130 MB) is downloaded here; no output for 1-3 min is normal
$ cmake --build alps-build -j$(nproc 2>/dev/null || sysctl -n hw.logicalcpu)
$ cmake --build alps-build -t test
-jcontrols parallel compilation. The expression above automatically uses all logical CPU cores on both Linux (nproc) and macOS (sysctl -n hw.logicalcpu). You can also set the number manually, e.g.-j 8for 8 cores.
Offline or slow-connection build: By default CMake fetches Boost 1.87 at configure time. To avoid the download, extract the archive manually first and pass the path:
$ cmake -S alps-src -B alps-build \ -DCMAKE_INSTALL_PREFIX=</path/to/install/dir> \ -DBoost_SRC_DIR=</path/to/boost_1_87_0> \ -DCMAKE_CXX_FLAGS="-DBOOST_NO_AUTO_PTR \ -DBOOST_FILESYSTEM_NO_CXX20_ATOMIC_REF"
Troubleshooting
Substitute the package names above with your cluster's module (e.g. [Intel MKL/OneAPI](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html), [AMD AOCL](https://www.amd.com/en/developer/aocl.html), etc). [Cmake](https://cmake.org/) is a build system that will find the locations of the above packages and generate compilation instructions in Makefiles. * **Python errors**
Ensure Python ≥ 3.9 is installed and that `numpy` and `scipy` are installed for the same Python that CMake selects. On macOS, CMake may pick the Xcode-bundled Python rather than your Homebrew/MacPorts Python — check the `Found Python:` line in the CMake output and pin the interpreter with `-DPython3_EXECUTABLE=/path/to/python3` if needed (see the [Verify Dependencies](#verify-dependencies) step). * **MPI mismatch?**
Ensure that CMake is using the same MPI version as `mpirun --version` * **Boost errors**
Building ALPS' Python bindings against NumPy ≥ 2.0 requires Boost ≥ 1.87 (NumPy 2.0 introduced API changes that only Boost 1.87+ handles). Boost 1.76–1.86 work only with NumPy < 2.0. See the [build notes](#build-notes) for tested compiler/Boost/Python combinations.
Build notes
The following combinations of Boost, Python and the C++ compiler have been tested:
- GCC 10.5.0, Python 3.9.19 (NumPy < 2.0) and
Boost1.76.0 - GCC 11.4.0, Python 3.10.14 (NumPy < 2.0) and
Boost1.81.0, 1.86.0 - GCC 12.3.0, Python 3.10.14 (NumPy < 2.0) and
Boost1.81.0, 1.86.0 - Clang 13.0.1, Python 3.10.14 (NumPy < 2.0) and
Boost1.81.0, 1.86.0 - Clang 14.0.0, Python 3.10.14 (NumPy < 2.0) and
Boost1.81.0, 1.86.0 - Clang 15.0.7, Python 3.10.14 (NumPy < 2.0) and
Boost1.81.0, 1.86.0
For NumPy ≥ 2.0, Boost 1.87.0 or later is required for ALPS’ Boost.Python bindings (CMake downloads this automatically).
If you have a non-standard installation location of the dependent packages installed in step 1, cmake will fail to find the package. ALPS uses the standard cmake mechanism (FindXXX.cmake) to find packages. The following pointers may help:
- For MPI: Follow the instructions on cmake with mpi
- For BLAS: Follow the instructions on cmake with BLAS
- For HDF5: Follow the instructions on cmake with HDF5
After successfully building the code, you will need to install it. The install location is specified with -DCMAKE_INSTALL_PREFIX=/path/to/install/directory as a cmake command during configuration. Alternatively, it can be changed by explicitly providing a new installation path to the --prefix parameter during the installation phase (see cmake manual).
To install the code run:
$ cmake --install alps-buildSet up your environment
The install directory is self-contained but your shell does not know about it yet.
ALPS provides a setup script that adds the right directories to PATH,
LD_LIBRARY_PATH, and PYTHONPATH. Source it once before using ALPS:
# bash / zsh:
$ source </path/to/install/dir>/bin/alpsvars.sh
# csh / tcsh:
$ source </path/to/install/dir>/bin/alpsvars.cshTo avoid running this command in every new terminal session, add the source line
to your shell’s startup file (~/.bashrc, ~/.zshrc, or ~/.cshrc).
Verify the installation by running one of the ALPS executables:
$ spinmc --helpIf the command is found and prints a help message, ALPS is installed and your environment is set up correctly.