User`s guide

C Shared Library Target
Note On Windows, if you want to have your shared library call a
MATLAB shared library (as generated by MATLAB Compiler), the
MATLAB library initialization function (e.g.,
<libname>Initialize,
<libname>Terminate, mclInitialize, mclTermi nate
) cannot b e called
from your shared library during the
DllMain(DLL_ATTACH_PROCESS) call.
This applies whether the intermediate shared library is implicitly or
explicitly loaded. You must place the call somewhere after
DllMain().
4 Call the exported functions of each library as needed. Use the C-M ex API
to process input and output arguments for these functions.
5 When your application no longer needs a given library, call the library’s
termination function. This function frees the resources associated with
its MCR instance. The library term ination function will be named
<libname>Terminate(),where<libn ame> is the library’s name that was
passed in on the command line when the library was compiled. Once a
library has been terminated, that library’s exported functions should not
be called again in the application.
6 When your application no longer needs to call any MATLAB Compiler
generated libraries, call the
mclTerminateApplication AP I f unction. This
function frees a pplicatio n-level resources used by the MCR. Once you call
this function, no further calls can be made to MATLAB Compiler generated
libraries in the application.
Loading Libraries in a Compiled Function
With MATLAB Compiler 4.0 (R14) and later,youcanuseM-fileprototypes
as described below to load your library in a compiled application. Note
that loading libraries using H-file headers is not supported in compiled
applications. This behavior occurs when
loadlibrary is compiled with the
header argument as in the statement:
loadlibrary(library, header)
In order to work a rou n d this issue, execute the following comman d at th e
MATLAB command prompt:
loadlibrary(library, header, 'mfilename', 'mylibrarymfile');
7-15