How to Install LAPACK on Mac OS
LAPACK already ships with macOS in Apple's Accelerate framework. If you want the latest version instead, here is how to install it with Homebrew.
On this page
Updated September 2026: new Homebrew install command, no GCC step, and the compiler flags you need to link Homebrew’s LAPACK.
Using Apple’s Accelerate Framework¶
This is a question I get asked a lot. LAPACK is actually included in the Accelerate library provided by Apple, so there is nothing to install. You include <Accelerate/Accelerate.h> in your C or C++ source code and compile with -framework Accelerate. Refer to this post for more information on how to use LAPACK included in Accelerate.
If you work in Python, you may not need to install anything either. NumPy and SciPy call LAPACK for you, and on macOS 14 and newer they use Accelerate. The solver post has a Python version of the example.
Installing the Latest LAPACK via Homebrew¶
If you like to use the latest version of LAPACK, you can easily install it using Homebrew. Enter the following command in a terminal window to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Installing LAPACK¶
Now, you can simply install LAPACK by typing the following command in a terminal window:
brew install lapack
Homebrew installs a prebuilt package, so you don’t need to install GCC or GFortran first.
Linking Against Homebrew’s LAPACK¶
Homebrew doesn’t add this LAPACK to the default compiler paths, because it would conflict with the one in Accelerate. You need to point the compiler to it. Homebrew lives in /opt/homebrew on Apple Silicon Macs and in /usr/local on Intel Macs, so it’s easier to let brew --prefix find the right folder:
LAPACK_PREFIX=$(brew --prefix lapack)
g++ my_program.cpp -I"$LAPACK_PREFIX/include" -L"$LAPACK_PREFIX/lib" -llapack -lblas -o my_program
The package also includes LAPACKE, the C interface to LAPACK. To use it, include <lapacke.h> in your code and add -llapacke to the command above. You can see these paths any time with brew info lapack.
Please let me know your questions in the comment section.