User`s guide

C++ Shared Lib rary Target
C++SharedLibraryTarget
In this section...
“C++ Shared Library Wrapper” on p age 7 -17
“C++ Shared Library Example” on page 7-17
C++ Shared Library Wrapper
The C++ library wrapper option allows you to create a shared library from
an arbitrary set of M-files. MATLAB Compiler generates a wrapper file and
a header file. The header file contains all of the entry points for all of the
compiled M-functions.
Note Even if you are not producing a shared library, you must use -W lib
or -W cpplib when including any MATLAB Compiler generate d code into a
larger application. For more information, refer to “Mixing M -Files and C
or C++” on page 6-13.
C++ Shared Library Example
This example rewrite s the previo us C shared library example using C++. The
procedure for creating a C++ shared l ib rary from M-files is identical to the
procedure for creating a C shared library, except you use the
cpplib wrapper.
Enter the following command on a single line:
mcc -W cpplib:libmatrixp -T link:lib addmatrix.m
multiplymatrix.m eigma trix .m -v
The -W cpplib:<libname> option tells MATLAB Compiler to generate a
function wrapper for a shared library and call it
<libname>.The-T link:lib
option specifies the target output as a shared library. N ote the directory where
MATLAB Compiler puts the shared library because you will need it later.
7-17