Build from source: Difference between revisions

From Octave
Jump to navigation Jump to search
(→‎Configure: Added introductory sentences)
(Added short introduction and a couple of sentences to the Build section)
Line 8: Line 8:


To compile Octave, you will also need a recent version of GNU Make. You must have GNU Make to compile octave. Octave's Makefiles use features of GNU Make that are not present in other versions of make. GNU Make is very portable and easy to install.  
To compile Octave, you will also need a recent version of GNU Make. You must have GNU Make to compile octave. Octave's Makefiles use features of GNU Make that are not present in other versions of make. GNU Make is very portable and easy to install.  
=Introduction=
Building Octave can be as simple as downloading the source and running the following three commands in your Linux shell:
./configure
make
make install
However, Octave is a complex program with many dependencies. This page details each of the steps, some issues that may arise with each step and the dependencies that Octave either requires, or will use if available.


=Dependencies=
=Dependencies=
Line 165: Line 175:


=Build=
=Build=
After running configure simply run


  make
  make
Note that the compilation of Octave can take some time.


==Troubleshooting==  
==Troubleshooting==  
Line 207: Line 221:


=Install=
=Install=
Finally, to install Octave on your system run


  make install
  make install
Line 215: Line 231:
*[[Octave for Mac|Mac OS X]]
*[[Octave for Mac|Mac OS X]]
*[[Octave_for_GNU_Linux:_Binary_Octave_packages_for_GNU_Linux#Debian_Development_Sources|Debian]]
*[[Octave_for_GNU_Linux:_Binary_Octave_packages_for_GNU_Linux#Debian_Development_Sources|Debian]]


=Distributed building=
=Distributed building=

Revision as of 10:59, 10 January 2012

Compiling from source is probably the most effective way of installing Octave on your system. To do this you will require compilers for the following languages:

  • C
  • C++ (ISO)
  • Fortran

The best supported compilers for the job are the GNU Compiler Collection. You will require at least GCC 4.3 or later, although GCC 4.4 or later is recommended.

To compile Octave, you will also need a recent version of GNU Make. You must have GNU Make to compile octave. Octave's Makefiles use features of GNU Make that are not present in other versions of make. GNU Make is very portable and easy to install.

Introduction

Building Octave can be as simple as downloading the source and running the following three commands in your Linux shell:

./configure
make
make install

However, Octave is a complex program with many dependencies. This page details each of the steps, some issues that may arise with each step and the dependencies that Octave either requires, or will use if available.

Dependencies

On Debian systems, many of the required build dependencies for all versions can be obtained through:

apt-get build-dep octave3.2

Which obtains the build dependencies for Octave version 3.2. Some of the required libraries and tools are listed below.

Tools

  • autoconf
  • automake
  • GNU sed
  • GNU awk
  • GNU make
  • nm
  • flex
  • bison
  • less
  • gperf (if building from scratch)
  • perl (also if building from scratch) or python
  • gnuplot
  • texinfo
  • ghostscript
  • a TeX? distribution (if building the documentation)

Libraries

Library Debian Package Name Comments
A version of BLAS and LAPACK, e.g. Atlas libatlas-base-dev
arpack libarpack2-dev New GPL-conformant version
curl libcurl4-gnutls-dev
fftw fftw3-dev
fltk libfltk1.1-dev
fontconfig libfontconfig1-dev
glpk libglpk-dev
GraphicsMagick libgraphicsmagick++1-dev
hdf5 libhdf5-mpich-dev
ncurses libncurses5-dev
PCRE libpcre3-dev
qhull libqhull-dev
qrupdate
readline libreadline5-dev
SuiteSparse libsuitesparse-dev Without metis due to licensing issues: UMFPACK - AMD - CAMD - COLAMD - CCOLAMD - CHOLMOD - CXSPARSE
zlib zlib1g-dev
Note for users of Debian stable "lenny", as of 2010/07/09, you can install these dependencies with
  
apt-get install autoconf automake flex bison gperf gnuplot libreadline5-dev libncurses5-dev zlib1g-dev \
    libatlas-base-dev fftw3-dev libglpk-dev libsuitesparse-dev libarpack2-dev libhdf5-mpich-dev \
    libpcre3-dev libcurl4-gnutls-dev libqhull-dev gfortran libfltk1.1-dev libgraphicsmagick++1-dev
  
Qrupdate is missing, but it is easy to install from http://qrupdate.sourceforge.net
You may need to add the line:  #include "GL/glu.h"    in src/DLD-FUNCTIONS/fltk_backend.cc.

Download

Released source tarballs are available at http://www.octave.org/download.html. You will normally want to use one of those.

The download page also contains instructions to download the development sources. If you are using the development sources, be sure to type the following command before configuring:

./autogen.sh

This builds the configure scripts that Octave uses. This requires a number of tools which are not needed if you download an octave release, such as recent versions of autoconf/automake, and tools such as bison, flex, gperf, perl, and maybe others.

Configure

Before compiling you must first configure the build system by running the configure script.

./configure

The configure script will display information about missing packages or any other issues that arise during the configuration run.

Octave has many configure options. For a complete list, see

./configure --help

If you are building a personal version, you will want to install it into your home directory, or perhaps a subdirectory. Add the following to your configure line:

--prefix=$HOME/octave

Be sure the $HOME/octave/bin is on your path, or symlink the binaries therein to $HOME/bin.

Troubleshooting

1. If you just type ./configure, you may get this error:

configure: WARNING: in order to build octave, you must have a compatible
configure: WARNING: Fortran compiler or f2c installed and in your path.
configure: error: See the file INSTALL for more information.

This means that you don't have a fortran compiler on your system. You can either install a fortran compiler or re-install gcc with its optional build-in fortran compiler g77. To do this you must download the g77 components of gcc before you build gcc. Alternatively there are various f2c programs you could install which convert fortran to C.

2. If you get this warning:

configure: WARNING: "FTGL headers not found. Native renderer will not have on-screen text"
configure: WARNING:
configure: WARNING: I didn't find the necessary libraries to compile native
configure: WARNING: graphics. It isn't necessary to have native graphics
configure: WARNING: but you will have to use gnuplot or you won't be able
configure: WARNING: to use any of Octave's plotting commands

It may help to call configure with CPPFLAGS=-I/usr/include/freetype2, please see Problems with FTGL building octave-3.1.51,Building ftgl backend with current tip. Note that from changeset 8269 onward, this workaround should no longer be needed, please see No FTGL, says configure script?

Build

After running configure simply run

make

Note that the compilation of Octave can take some time.

Troubleshooting

Another possible error occurs at the 'make' stage:

/usr/include/c++/3.3.1/bits/basic_string.h:228: undefined reference to 
    `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_empty_rep_storage'
collect2: ld returned 1 exit status
make[2]: *** [octave] Error 1

This has something to do with the gcc configuration. Try compiling the following program using g++:

#include <string>
#include <iostream>
using namespace std;
int main (void)
{
  basic_string <char>a = "thing one";
  string b = "thing two";
  cout << a.c_str() << endl;
  return (a == b);
}

If it fails, then your compiler needs to be set-up differently (how?). On my machine I can compile that test program but still get the error making Octave -- how do we solve this? It has something to do with the shared C++ library versions, check for /usr/lib/libstdc++.so.6 and make sure the right version of that library is being used by gcc -- especially if you had to reinstall gcc to build the fortran support. If it still doesn't work, consider installing from the RPMs instead of compiling from source.

Test

To run all tests, change to the octave directory and type

make check

This requires dejagnu.

To run a specific set of tests, change to the directory test/octave.test/<part> and type

runtest <part>.exp

To run your own tests use the RunInPlace shell script.

Install

Finally, to install Octave on your system run

make install

System Specific Instructions

Distributed building

Requirements

distcc
ccache

Install distcc on all machines taking part in the compilation. List them in ~/.distcc/hosts:

localhost
pc1.mynet.org
pc2.mynet.org

The first machines listed are given higher priority -- place 'localhost' as you see fit.

Set the environment variables CCACHE_PREFIX, CXX and CC:

export CCACHE_PREFIX="distcc"
export CXX="ccache g++"
export CC="ccache gcc"
./configure <options>

Compile using the -j<simultaneous-jobs> flag, two jobs per CPU available, i.e. for 5 machines

make -j10