User`s guide

5 Controlling Code Generation
5-24
This example uses several functions from the toolbox\matlab\timefun
directory (weekday, date, tic, calendar, toc) to creat e a library wrapper. Th e
-W lib:libtimefun -L C options produce the files shown in this table.
libtimefun.c
TheCwrapperfile(libtimefun.c) contains the initialization
(
libtimefunInitialize) and termination (libtimefunTerminate) functions
for the library. You must call
libtimefunInitialize before you call any
Compiler-generated code. This function initializes the state of
Compiler-generated functions so that those functions can be called from C code
notgeneratedbythe Compiler. You mustalsocall
libtimefunTerminate before
you unload the library.
The library files in this example are produced from the command
mcc -W lib:libtimefun -L C weekday date tic calendar toc
C Shared Library
The MATLAB Com piler allows y ou to build a shared library from the files
created in the previous section, “C Librari es.” To build the shared library,
libtimefun.ext,inonestep,use
mcc -W lib:libtimefun -L C -t -T link:lib -h weekday date tic calendar toc
The -t option tells the Compiler to generate C code from each of the listed
M-files. The
-T link:lib option tells the Compiler to compileand link a shared
library. The
-h option tells the Compiler to include any other M-functions
called from those listed on the
mcc command line, i.e., helper functions.
File Description
libtimefun.c
C wrapper file
libtimefun.h
C header file
libtimefun.exports
C export list
libtimefun.mlib
M-file library