GNU Octave is a high-level interpreted language and software, primarily intended for numerical computations. Historically it has been solely run from the command-line (that is, through a terminal emulator) but since version 3.8.0 a graphical user interface (GUI) has been available as part of the software.
Figure 1: Screenshot of the GNU Octave 4.0.0 command-line interface
GNU Octave is a high-level interpreted language that is mostly MATLAB(R)-compatible and is primarily intended for numerical computations. It provides a convenient command line interface (CLI) for solving linear and nonlinear problems numerically, although since version 3.8.0 (which is available in the official repositories for Ubuntu 14.04 and later) a graphical user interface (GUI) has also been available for the software (for versions 3.8.x this GUI may be called by running octave --force-gui
). Octave uses some of the best and most respected numerical libraries and it can be dynamically extended with user-supplied C++ files.
Figure 2: Screenshot of the GNU Octave 4.0.0 GUI in the Xfce desktop environment
Installing GNU Octave
Installation of Octave on Ubuntu is usually easiest done via APT or the Ubuntu Software Center, although installation from source is a viable alternative if one would prefer a different version of the software (like, for example, the latest version) to that available in the Ubuntu repositories. Installing GNU Octave from source is simple in itself (although it often takes hours of time, most of which is without the need for user input), but what makes the whole process more time-consuming and complicated is getting all the dependencies, fortunately, however the configure
file that comes with the source code of GNU Octave often tells one when one is missing a dependency, or if a dependency is not available to the Octave during compilation.
Installing GNU Octave from source
Source code tarballs for GNU Octave may be found here. Alternatively if one knows the precise version of GNU Octave one wants one can use wget to get it, via:
ver=4.0.0 #Replace 4.0.0 with the version one wants.
wget -c https://ftp.gnu.org/gnu/octave/octave-$ver.tar.gz
A list of dependencies for Ubuntu systems (including their names in the Ubuntu repositories) can be found here at the official GNU Octave Wiki. Although this list may become out-dated, an alternate source for build dependencies is here, which is the official documentation for GNU Octave, but keep in mind this page can lag behind the updates too (e.g., as of 19 July 2015 this documentation was last updated in 2013) and does not give one the name of these dependencies as they appear in the Ubuntu repositories. Many of these dependencies could be installed by running sudo apt-get install build-dep octave
. Once one believes one has all the dependencies required, extract the tarball into a desired directory and run the command trinity (that is, ./configure && make && sudo make install
). For example, to extract the tarball and run the trinity, one could run:
tar -xzf octave-$ver.tar.gz
cd octave-$ver
./configure
make
sudo make install DESTDIR=/
It may be worthwhile only copying up to the ./configure
stage, as the ./configure
command will likely tell one if one is missing any required dependencies. For example, if the ./configure
command gives:
Warning: HDF5 library not found. Octave will not be able to save or load HDF5 data files.
even though one is sure that HDF5 is installed on one's system, then in accordance with the answer given to this bug report, the ./configure
line should be amended to:
./configure CPPFLAGS=-I/usr/include/hdf5/serial LDFLAGS=-L/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/hdf5/serial
Likewise one may receive a warning that Java was not found and hence autodetect will be used, but is unreliable. In this case look for the home directory for Java on your system, then at the ./configure
line set it as your JAVA_HOME
variable. For example, if you have a 32-bit system your ./configure
line will likely be something like ./configure ... JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
, where ...
could be blank, or could include the HDF5 bug solution outlined earlier in this tag wiki.