Install Octave 4 on Mac OS X El Capitan
To install GNU Octave on a Mac is not as easy as on Microsoft Windows® or GNU/Linux.
Ready-to-use App bundles are outdated and/or do not run reliably. The installation with a package manager as MacPorts or Home Brew does not work out-of-the-box.
EDIT: For more current macOS versions reliable app bundles are available at octave-app.org.
This How-To describes how to install Octave 4.0.3 with MacPorts (Version 2.3.4) on Mac OS X 10.11 (El Capitan). It shows how to avoid pitfalls and workaround bugs.
I already updated the Octave Wiki based on this how-to. But that description is brief. Here you find the detailed instructions.
First: Take your time. The installation and more important, the compilation of some parts take several hours. Be patient.
MacPorts is a package manager which is based on BSD-Unices.It provides UNIX programs in packages – so-called “ports” – which are not distributed by Apple. Due to the fact that MacPorts provides the sources only, it is necessary to compile them. This takes longer than just download an already compiled app bundle. But do not worry, all these is done semi-automatically by typing a few commands.
MacPorts installs the ports and itself in the directory /opt/local which you can not view by the Finder directly. But in the case of GUI-Programs MacPorts provides App Bundles in the Program directory for easy access.
- We need the “Xcode Developer Tools” first. Since OS X 10.9 (Mavericks) you do not need to install Xcode to get the “Xcode Developer Tools”. Open a Terminal (Applications/Utilities) and type the following command:
and follow the displayed instructions to install the tools . Then type:
sudo xcodebuild -license
and confirm with “agree” and ENTER.
- Now download MacPorts for your Mac OS X version and run the PKG-installer.
- After the installation process finished MacPorts is installed on your Mac.
Install the “Octave” Port
The new Octave 4.0.3 should install out-of-the-box with:
sudo port install octave
The basic installation may work for most people. But for some reasons the next lines are worth reading.
The new Octave port is compiled with the accelerate variant by default. This might cause problems later. For this reason the atlas variant is a better choice. But it will consume more (compilation) time.
- The port “atlas” – an import math library – does not compile with the default variant. You need to to choose the gcc5 variant. Type in the Terminal:
sudo port install atlas +gcc5
Note: The compilation of “atlas” lasts for a lot of hours, even on modern hardware. I recommend to run this command over night.
- Another dependency of Octave which could make problems later by using Octave is the math library “arpack”. Per default it will be compiled with Apple’s accelerate variant which is buggy. Compile it with atlas:
sudo port install arpack -accelerate+atlas
It is also possible to run this command after the installation of Octave.
- Now all preliminaries are finished and you can install Octave itself. Now the graphical user interface (GUI) will be installed by default. But for using the atlas library and the Java dialog functions I recommend to install Octave with the following variants:
sudo port install octave -accelerate+atlas+java
The compilation of Octave lasts some time but not as much as “atlas” by far.
- After the installation finished you find an app bundle of Octave in the Launchpad and in the directory “Applications”. It is also possible to run the command-line version of Octave in the terminal by typing the command octave.
For the Java dialog functions you need a Java JRE installed. Download it from Oracle.
After starting Octave I noticed some peculiarities. Most of them are from optical nature:
- The first plot lasts a while after starting Octave. The next one appears immediately. Windows users have the same problem.
- The font size of the command window is even on my non-retina Macbook to small by far. But you can correct this in the settings.
- Labels in buttons, in the editor’s submenu and other widgets are not centered vertically (Screenshot).
In comparison to the GNU/Linux or even the Windows® version Octave looks less polished on a Mac via MacPorts. I read that via Home Brew similar effects were observed.
Improvements in comparison to version 3.8.3
In comparison to version 3.8.2 some bugs and peculiarities are removed:
- Plotting works out-of-the-box.
- Octave gets the focus after starting now and is not coated by the current window anymore.
- The error message after closing the settings dialog box is gone.
- The command cd seems not to be ignored in the start file ~/.octaverc anymore.
Update Problems from 3.8.2
If you have problems from the old 3.8.3 port because of incompatible variants, refer Octave 4 upgrade via MacPorts fails after “port upgrade outdated”