User`s guide
C++ Shared Lib rary Target
Compiling the Driver Application
To compile the matrixdriver.cpp driv er code, you use your C++ compiler.
By executing the following
mbuild command that corresponds to your
development platform, you will use your C++ compiler to compile the code.
mbuild matrixdriver.cp p libmatrixp.lib (Windows)
mbuild matrixdriver.cp p -L. -lmatrixp -I. (UNIX)
Note This command assumes that the shared library and the corresponding
header file are in the current work in g directory.
On Windows, if this is not the case, specify the full path to
libmatrixp.lib,
and use a
-I option to specify the directory co ntaining t he header file.
On UNIX, if this is not the case, replace the “
.” (dot) following the -L and -I
options with the name of the directory that contains these files, re spectiv ely.
Incorporating a C++ Shared Library into an Application
To incorporate a C+ + shared library into your application, yo u will, in general,
follow the steps in “Using a Shared Library” on page 7-14. There are two main
differences to note when using a C++ shared library:
• Interface functions use the
mwArray type to pass arguments, rather than
the
mxArray type used with C shared libraries.
• C++ exceptions are used to report errors to the caller. Therefore, all calls
must be w rapped in a
try-catch block.
Exported Function Signature
The C++ shared library targe t gen erates two sets of interfaces for each
M-function. The first set of exported interfaces is identical to the
mlx
signatures that are generated in C shared libraries. The s econd s et of
interfaces is the C++ function interfaces. The generic signature of the
exportedC++functionsisasfollows:
7-21