MATLAB Compiler Previous page   Next Page

MATLAB Compiler-Generated Interface Functions

A shared library generated by the MATLAB Compiler contains at least seven functions. There are three generated functions to manage library initialization and termination, one each for printed output and error messages, and two generated functions for each M-file compiled into the library.

To generate the functions described in this section, first copy sierpinski.m and triangle.c from <matlabroot>/extern/examples/compiler into your directory, and then execute the appropriate Compiler command.

For a C application

On Windows.   

On UNIX.   

For a C++ application

On Windows.   

On UNIX.   

These commands create a main program named triangle, and a shared library named libtriangle. The library exports a single function that uses a simple iterative algorithm (contained in sierpinski.m) to generate the fractal known as Sierpinski's Triangle. The main program in triangle.c or triangle.cpp can optionally take a single numeric argument, which, if present, specifies the number of points used to generate the fractal. For example, triangle 8000 generates a diagram with 8,000 points.

sierpinski triangle containing 8,000 points

In this example the MATLAB Compiler places all of the generated functions discussed below into the generated file libtriangle.c or libtriangle.cpp.


Previous page  C++ Shared Library Example Structure of Programs That Call Shared Libraries Next page

© 1994-2005 The MathWorks, Inc.