Building TIM Matlab

Back to TIM 1.2.0

This page describes how to build the TIM Matlab interface. This is only necessary if prebuilt binaries are not available for your platform at the main page. To be able to build the TIM Matlab interface, you need to first build the TIM libraries.

Build process

Matlab uses special kinds of shared libraries to extend it. These are called mex files. The building process for such files must be driven from Matlab, because this is the only way that the approriate libraries will get linked into the resulting mex library, no matter what the Matlab version. Matlab redirects the compilation and linking to an external compiler, such as Visual Studio or gcc.

1. Select a compiler

To select the compiler Matlab uses, type

mex -setup

on the Matlab command line, and follow the instructions. A compiler can be used to build the TIM Matlab interface if

The current list of supported compilers for Matlab 2010b can be found from here. There is a similar list for the previous versions.

Note: since OpenMP was introduced in gcc 4.2, and the supported compiler for Mac OS X is only of version 4.0, it is not currently possible to build TIM in Mac OS X with OpenMP enabled.

Note: Matlab 32-bit is required to build 32-bit mex files, and Matlab 64-bit is required to build 64-bit mex files. In particular, it is not possible to do 32-bit builds from Matlab 64-bit.

2. Set the external library directories

In tim/matlab directory, open the file build_tim.m, which will read something like this:

mex tim_matlab.cpp ...
    -D_HAS_ITERATOR_DEBUGGING=0 ...
    -DPASTEL_ENABLE_OMP ...
    -I'../../../pastel' ...
    -I'../../../tim' ...
    -I'../../../../external/boost_1_45_0' ...
    -L'../../../pastel/build/vs2008/lib/release' ...
    -L'../../../tim/build/vs2008/lib/release' ...
    -lTimMatlab ...
    -lTimCore ...
    -lPastelGeometry ...
    -lPastelMath ...
    -lPastelMatlab ...
    -lPastelSys

Replace the directories to reflect the locations of the libraries. The I is for an include directory, while L is for a library directory. There are similarly named build files for debug, develop, and release-without-openmp modes.

3. Add some flags and libraries

To enable OpenMP (support for multiple cores), do the following:

On the 64-bit Linux, if you want to build the 32-bit version (requires Matlab 32-bit), add the -m32 compiler flag in the g++ flags of the glnx86 section in the options file.

4. Choose configuration and build

To build TIM Matlab in release mode, type in Matlab command line:

>> build_tim

Alternatively, you can build the TIM Matlab interface in other modes by running the script with the desired configuration.

Output files

The only output file from this process is the tim_matlab mex file.

Files

TIM Matlab interface build file

tim_matlab.cpp

tim_matlab.h

TIM Matlab interface debug build script

build_tim_debug.m

TIM Matlab interface develop build script

build_tim_develop.m

TIM Matlab interface release build script

build_tim.m

TIM Matlab interface release-without-openmp build script

build_tim_release_without_openmp.m