Compile Octave 4.4 on Ubuntu 18.04

2 minute read

Related: 10 second Octave 4 PPA install


One might choose to compile GNU Octave if the Octave PPA is too old or not available for your Linux system. 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
    
  3. Compile GNU Octave Source
    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"
    
  4. Install GNU Octave–takes 30-60 minutes:

    make -j -l4 CFLAGS=-O CXXFLAGS=-O LDFLAGS=
    make install
    

    Note, normally you can just use make -j to “max out” the full capability of your CPU cores + threads. However, with a huge program like Octave, this can make your PC stop responding to user input for an hour or more. So limit make to two jobs with make -j -l2.

  5. Tell Linux to use this new GNU Octave by adding to ~/.bash_aliases
    alias octave="$HOME/.local/octave/bin/octave -q"
    
  6. 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

Leave a comment