MacOS - Open-Quantum-Platform/openqp GitHub Wiki

The MacOS requires special attention to the installation of prerequisites.

  1. Install and update Homebrew assuming bshell environment.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install cmake and ninja.
brew install cmake ninja
  1. Download OQP.
git clone https://github.com/Open-Quantum-Platform/openqp.git
  1. We should use gcc by Homebrew rather than the gcc provided by OSX. Typically, the gcc by Homebrew has a specific version number on its name like gcc-11. Assuming you have version 11 of gcc, the cmake script should be modified as
cd to where OQP is installed
cmake -B build -G Ninja -DUSE_LIBINT=OFF -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_Fortran_COMPILER=gfortran-11 -DCMAKE_INSTALL_PREFIX=. -DENABLE_OPENMP=ON -DLINALG_LIB_INT64=OFF

Apple provides the BLAS and LAPACK libraries under the Accelerate framework. Therefore, cmake should find its intrinsic libraries during cmake run such as

-- Found BLAS: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/Accelerate.framework
-- Found LAPACK: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/Accelerate.framework;-lm;-ldl

If your macOS version too outdated, you need to re-run cmake by installing BLAS such as

brew install openblas
  1. Installation can be done by the two commands. Depending on environment, pip should be replaced by pip3.
ninja -C build install
pip install pyoqp/.

Going back to Installation