Building

From Octave
Revision as of 06:52, 28 October 2019 by Siko1056 (talk | contribs) (→‎Tweaks: Overhaul section.)
Jump to navigation Jump to search
This article provides general information about building GNU Octave from source.

General steps

  1. Install all build dependencies (see below).
  2. Getting the Octave sources ...
    • ... from the development repository
hg clone https://www.octave.org/hg/octave && \
cd octave                                  && \
./bootstrap
  • ... from a release
wget https://ftpmirror.gnu.org/octave/octave-9.2.0.tar.gz && \
tar -xzf octave-9.2.0.tar.gz                               && \
cd octave-9.2.0
3. Configure, build, check, and install Octave
mkdir .build                            && \
cd    .build                            && \
./../configure --prefix=$HOME/my_octave && \ [1]
make -j2                                && \ [2]
make check                              && \
make install

Dependencies

Most of the dependencies given in this section can be very conveniently installed on many GNU/Linux systems. Please read the respective wiki page for your distribution on the Octave for GNU/Linux page.

On MS Windows and macOS systems the generic Octave build process described on this page needs some more effort to fulfill the described build dependencies. Please read Octave for Microsoft Windows and Octave for macOS for information how to build Octave for the respective systems.

Dependencies marked with green background are required for building Octave. All other tools and libraries are recommended/optional, but very useful features (like the GUI, plotting, etc.) are likely to be disabled.

Build tools

Dependency Description License / Copyright
Autoconf Software configuration GNU GPL v3.0
Automake Makefile generator GNU GPL v3.0
C++, C, and Fortran compilers Compiling the source code GNU GPL v3.0
GNU Make Makefile processor GNU GPL v3.0
Libtool Dependency of automake Free Software Foundation
Unix utilities: gawk, gperf, less, ncurses Miscellaneous tasks GNU GPL v3.0
Bison Parser generator GNU GPL v3.0
Flex Lexical analyzer The Flex project

Documentation tools

Dependency Description License / Copyright
epstool Epstool is a utility to create or extract preview images in EPS files, fix bounding boxes and convert to bitmaps. GNU GPL v2.0
FTGL Portable font engine to perform font rendering for Octave’s OpenGL-based graphics functions. GNU GPL v2.0
GL2PS GL2PS is a C library providing high quality vector output for any OpenGL application. GNU LGPL v2.0
Texi2HTML Perl script which converts Texinfo source files to HTML output. GNU GPL v3.0
Texinfo Documentation system that uses a single source to produce both on-line information and printed output. GNU GPL v3.0
TeX Live TeX document production system including all the major TeX-related programs, macro packages, and fonts that are free software. Freely redistributable as defined by the Free Software Foundation

External tools and libraries

Dependency Description License / Copyright
BLAS Basic Linear Algebra Subroutine library Free - proper attribution request
LAPACK Linear Algebra Package Free - proper attribution request
PCRE Perl Compatible Regular Expression library Free
GNU Readline Command-line editing library GNU GPL v3.0
ARPACK-NG Solution of large-scale eigenvalue problems BSD like - various authors
cURL Library for transferring data with URL syntax Free Software -- main author
FFTW3 Library for computing discrete Fourier transforms MIT -- GNU GPL v2.0
FLTK Portable GUI toolkit GNU GPL v2.0 with static linking exception
fontconfig Library for configuring and customizing font access Provided "as is" -- various authors
FreeType Portable font engine compatible with GNU GPL v3.0
GLPK GNU Linear Programming Kit GNU GPL v3.0
gnuplot Interactive graphics program Provided "as is" -- various authors
GraphicsMagick++ Image processing library various -- integrates many third-party libs
HDF5 Library for manipulating portable data files BSD - like
OpenGL API for portable 2D and 3D graphics Free specs -- license is driver dependent
Qhull Computational geometry library Free software -- specific
QRUPDATE QR factorization updating library GNU GPL v3.0
SuiteSparse Sparse matrix factorization library Main author
zlib Data compression library Provided "as is" -- various authors

Tweaks

Install Octave in home directory

To install multiple versions of GNU Octave on one system, it is recommended to use the --prefix option of the configure script. With this option one can determine a custom installation directory, preferably within your user's home directory, to avoid elevated installation privileges. One does not "clutter" the system by running sudo make install and the custom build Octave can coexist with, for example, your Linux distribution installation of Octave.

In order to start the custom build of Octave almost as convenient as the Linux distribution installation of Octave, one can create an alias within .bashrc:

echo "alias octave38='~/.octave38/bin/octave'" >> ~/.bashrc
. ~/.bashrc # this will update your bashrc without doing logout and login!

If you simply enter octave, you'll start your Linux distribution installation of Octave. But when you enter octave38, you'll start your custom build of Octave inside your home directory.


Managing your own program hierarchy (optional)

If you intend to compile for yourself a lot of utilities, you may use a specific "usr" hierachy into your own dir (Linux from scratch way). Go back to step 2, and configure octave as:

./configure --prefix=${HOME}/usr

The other steps (make; make install) do not change. In order to use your own hierachy, you should set a few environment variables in your .profile:

 # set LD_LIBRARY_PATH if not set
 (echo $LD_LIBRARY_PATH | grep -q lib) || export LD_LIBRARY_PATH="/usr/local/lib:$HOME/usr/lib:$HOME/usr/local/lib"

 # set PATH so it includes user's private bin if it exists
 if [ -d "$HOME/bin" ] ; then
       (echo $PATH | grep -q $HOME/usr/bin) || export PATH="$HOME/bin:$HOME/usr/bin:$HOME/usr/local/bin:$PATH"
 fi
 
 # set MANPATH so it includes user's private bin if it exists
 if [ -d "$HOME/usr/share/man" ] ; then
   (echo $MANPATH | grep -q $HOME/usr/share/man) || export MANPATH="$HOME/usr/local/share/man:$HOME/usr/share/man:`manpath -q`"
 fi
 
 if [ -d "$HOME/usr/share/info" ]; then
   export INFOPATH="$INFOPATH:$HOME/usr/share/info"
 fi
 
 if [ -d "$HOME/usr/lib/python" ]; then
   (echo $PYTHONPATH | grep -q $HOME/usr/lib/python) || export PYTHONPATH="$HOME/usr/local/lib/python:$HOME/usr/lib/python"
 fi
 
 if [ -d "$HOME/usr/lib/pkgconfig" ]; then
   (echo $PKG_CONFIG_PATH | grep -q $HOME/usr/lib/pkgconfig) || export PKG_CONFIG_PATH="$HOME/usr/lib/pkgconfig"
 fi

This way, most ordinary commands like "man octave", "info octave", or launching octave itself, will first explore your own hierachy.

Uninstall

  1. If you still have the .build folder, just run make uninstall from it.
  2. Just delete the install folder, e.g. rm -rf $HOME/my_octave.

In any case, don't forget to remove any created alias entries in ~/.bashrc.

See also

Footnotes

  1. --prefix determines the installation location.
  2. Depending on your system and processor count, use a larger number of parallel jobs, e.g. -j8.