Error Message /usr/local/lib/libgfortran.3.dylib (no such file) on Intel Mac Solved

If you ran into this problem when you tried to run some .mexmaci files, here is how you fix the error.

A user tried to use a Matlab toolbox which uses some .mexmaci files. Part of the error mesage is ‘/usr/local/lib/libgfortran.3.dylib’ (no such file). This is because the .mexmaci was compiled using libgfortran.3.dylib and the file is not on the machine. This file is part of gcc@6 on Homebrew. In order to fix this problem, we need to install Homebrew and use Homebrew to install gcc@6. Note that this only applies to Intel Mac. If you have the the new Apple Silicon Mac, you are out of luck.

  1. Install Homebrew if you don’t have it already. Open a Terminal window and type
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Follow the instructions to finish the installation of Homebrew. You might need to type some commands to add Homebrew to your PATH variable.
  3. Install gcc
    brew install gcc@6 
  4. Create a symbolic link
    sudo ln -s /usr/local/Cellar/gcc@6/6.5.0_7/lib/gcc/6/libgfortran.3.dylib /usr/local/lib/libgfortran.3.dylib

Now you are ready to try to run that .mexmaci files again.


This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.


Be the first to comment

Leave a Reply