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.

If you’re thinking about purchasing a new GPU, we’d greatly appreciate it if you used our Amazon Associate links. The price you pay will be exactly the same, but Amazon provides us with a small commission for each purchase. It’s a simple way to support our site and helps us keep creating useful content for you. Recommended GPUs: RTX 5090, RTX 5080, and RTX 5070. #ad

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.

Be the first to comment

Leave a Reply