Compile Octave 4.4 on Ubuntu 18.04

Related: Easy 10 second Octave install


One might choose to compile GNU Octave to use the latest development source. However, most users should instead download Octave or on Linux install Octave flatpack

Compile

This procedure was tested with Ubuntu 18.04, g++ 7.3, LLVM 6.0 and Java/OpenJDK 10.

  1. core prereqs
   apt install g++ make gawk gfortran gnuplot texi2html icoutils libxft-dev gperf flex libbison-dev libqhull-dev libglpk-dev libcurl4-gnutls-dev librsvg2-dev libqrupdate-dev libgl2ps-dev libarpack2-dev libreadline-dev libncurses-dev libhdf5-dev llvm-dev default-jdk texinfo libfftw3-dev libgraphicsmagick++1-dev libfreeimage-dev transfig epstool librsvg2-bin libosmesa6-dev libsndfile-dev lzip libatlas-base-dev liblapack-dev libsundials-dev
   

graphical prereqs–if you only want the command line Octave + GNUplot-based plotting, you can OMIT these prereqs:

   qtbase5-dev qttools5-dev libqscintilla2-qt5-dev
   

Octave development prioritizes Qt over the other two GUI methods (FLTK, GNUplot). 2. Download GNU Octave source octave-*.tar.lz and extract

   tar -xf octave-4*.lz
   
  1. Configure GNU Octave build
   mkdir ~/.local/octave
   

in the directory where you extracted Octave source:

   ./configure --prefix=$HOME/.local/octave
   

configure takes a minute or two, perhaps several minutes on slower systems. Usually it will tell you if a prerequisite library is missing.

Configure Octave 4.4 results

If you get errors with conflicting libraries, try before the ./configure command:

   export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   
  1. Install GNU Octave–takes 30-60 minutes:
   make -j -l2 CFLAGS=-O CXXFLAGS=-O LDFLAGS=

   make install
   

limit make resource usage with make -j -l2. 5. Tell Linux to use this new GNU Octave by adding to ~/.bashrc

   export PATH="$HOME/.local/octave/bin/:$PATH"
   
  1. Configure ~/.octaverc to nicer defaults.

(optional) test Octave build

make check

results in:

PASS                            14981
FAIL                                0
XFAIL (reported bug)               35
SKIP (missing feature)             71
SKIP (run-time condition)          12

Notes

GNU Octave hard to read font fix

If fonts look terrible in GNU Octave Terminal or Editor, fix by changing to a better font:

  1. Edit → Preferences → Terminal → Font → Liberation Mono
  2. Edit → Preferences → Editor Styles → Octave → Default → Liberation Mono

Other fixes

libinterp/corefcn/jit-typeinfo.cc:216:1: error: ‘octave_jit_octave’ has not been declared octave_jit_octave::err_nan_to_logical_conversion (void)

This error (for Octave 4.2) comes from the non-functioning JIT; please do not use --enable-jit at ./configure with Octave 4.2.


lrelease: could not exec ‘/usr/lib/x86_64-linux-gnu/qt5/bin/lrelease’: No such file or directory

this error fixed by

apt install qttools5-dev-tools