Build from source

From Octave
Revision as of 22:01, 1 March 2012 by Jwe (talk | contribs) (→‎Configure)
Jump to navigation Jump to search

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

More detailed instructions for building from source are included in the Octave manual.

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

Alternatively, If you have checkinstall on your system issue

checkinstall -D

This will create a deb from the sources and register the installation with dpkg.

checkinstall -R

will create RPM package which you can install using your package manager in RPM based distributions.

System Specific Instructions

Distributed building

Requirements

The following seems to be out of date for my Ubuntu setup. My suggestion would be to look at the latest info for distcc and follow the instructions from there. Make sure the different machines have the same software. DAS


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