User`s guide

MATLAB Compiler Generated Interface Functions
In this example, MATLAB Compiler places all of the generated functions into
the generated file
libtriangle.c or libtriangle .cpp .
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 mcl Init ializeApplication, and test for success. This function sets
up the global M CR state and enables the construction of MCR instances.
3 Call, once for each library, <libraryn ame> Initialize, to create the M CR
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 varia bles, close files, etc., and exit.
To see these steps in an actual example, review the main program in this
example,
triangle.c.
Library Initialization and Termination Functions
The library in itializati on and termination functions create and destroy,
respectively, the MCR instance required by the shared library. You must c a ll
the initialization function before you invoke any of the other functions in the
shared library, and you should call the termination function after you are
finished making calls into the shared library (or you risk leaking memory).
Therearetwoformsoftheinitializationfunctionandonetypeoftermination
function. The simpler of the two initialization functions takes no arguments;
7-25