Building gmt-mex for Octave

The GMT/MATLAB toolbox also works in Octave (4.0.x) but seems less stable than the MATLAB version. First make sure you have installed Octave and the mkoctfile executable (usually distributed via a liboctave-dev package, such as under Ubuntu). The steps to build gmt-mex against Octave should ideally be similar under any UNIX/Linux system, including OS X):

  1. Install the GMT 5.3.1 from apt-get or build from source via the main GMT Download page.
  2. Obtain the gmt-mex source code: cd into a suitable directory for development (e.g., GMTdev) and run
    svn co svn://gmtserver.soest.hawaii.edu/gmt-mex/trunk gmt-mex
  3. Make sure GMT 5.3.1 is in your path; Use gmtswitch to select your active GMT version if you have more than one installed (see the gmtswitch documentation if you have never used this facility before).
  4. In the gmt-mex directory, run
    autoconf
    ./configure --enable-octave
  5. Then cd into src and run
    make all
    make install
    This should build the gmtmex.mex application, which is needed by the gmt.m script you will be using, and install them with the rest of the GMT executables.
  6. Add the GMT path to your Octave path, or alternatively copy these two files to a place where Octave can find them.
  7. If your GMT libraries are not in the standard directories you need to run
    export LD_LIBRARY_PATH=<path-to-libgmt.so-dir>
    to include the path to libgmt.so.
  8. Start Octave and type "gmt"