Install Octave on OSX EI Capitan 10.11.3

Installing Octave on the latest OSX can be error prone. One may download the Octave-Forge bundle from sourceforge here which however is large and also a bit out of date.

Alternatively, if you use homebrew to do this, please be ware of
a few traps. Here are the steps I adopted to successfully install Octave.
If you do not have Xcode or Homebrew installed yet, please refer to Google
to get them installed properly.

1. Preliminaries

  • Install XQuartz from here.
  • Install gcc with (this is for gfortran).
1
$ brew install gcc

It may take quite some time to install gcc from source. If you cannot wait, do xcode-select –install before install gcc. This will have mac install a pre-compiled version which is very fast.

2. Import the scientific computing packages with

1
2
$ brew update && brew upgrade
$ brew tap homebrew/science

If you see any warnings, run

1
$ brew doctor

and follow any suggestions to fix the problem. And then re-import the packages as follows

1
2
$ brew untap homebrew/science
$ brew tap homebrew/science

3. Install Octave

1
$ brew install octave --without-docs

The option –without-docs above is to suppress errors due to missing Tex installation.

4. Install gnuplot

As gnuplot will automatically be installed with octave, but without support for X11. So we need to reinstall it properly.

1
2
$ brew uninstall gnuplot
$ brew install gnuplot --with-x

To me, I still got the following warnings after the steps above.

1
2
warning: ft_render: unable to load appropriate font
warning: could not match any font: *-normal-normal-10

It can be fixed by following this stack overflow post. Simply put it here where you should add this line into your ~/.bash_profile.

1
export FONTCONFIG_PATH=/opt/X11/lib/X11/fontconfig

And run

1
$ source ~/.bash_profile

to reload the config within your terminal. Alternatively, you could restart your teminal.

5. Configurations

Put the following configurations into ~/.octaverc. If there’s no such file, just create one yourself.

1
2
3
4
setenv ("GNUTERM", "X11")

# optional if you are in favor of a more elegant prompt.
PS1('❯❯ ')