MATLAB Compiler Previous page   Next Page

Structure of Programs That Call Shared Libraries

All programs that call MATLAB Compiler-generated shared libraries have roughly the same structure:

  1. Declare variables and process/validate input arguments.
  2. Call mclInitializeApplication, and test for success. This function sets up the global MCR state and enables the construction of MCR instances.
  3. Call, once for each library, <libraryname>Initialize, to create the MCR instance required by the library.
  4. Invoke functions in the library, and process the results. (This is the main body of the program.)
  5. Call, once for each library, <libraryname>Terminate, to destroy the associated MCR.
  6. Call mclTerminateApplication to free resources associated with the global MCR state.
  7. Clean up variables, close files, etc., and exit.

To see these steps in an actual example, review the main program in this example, triangle.c.


Previous page  MATLAB Compiler-Generated Interface Functions Library Initialization and Termination Functions Next page

© 1994-2005 The MathWorks, Inc.