Sei sulla pagina 1di 4

MBUILD Compile an executable from C source code

Usage:
mbuild [options ...] file [files ...]
Description:
MBUILD compiles and links source files that call functions in the
shared libraries generated by MATLAB Compiler. The result is a
stand-alone executable or shared library.

MBUILD accepts any combinations of source files, object files, and
library files as arguments.
The command line options to MBUILD are defined in the "Command Line
Options" section below.

You can run MBUILD from the MATLAB Command Prompt, Windows Command
Prompt, or the UNIX shell. MBUILD is a script named mbuild.bat on
Windows and mbuild on UNIX, and is located in the directory
specified by [matlabroot '/bin'].

The first file name given (less any file name extension) will be the
name of the resulting executable. Additional source, object, or
library files can be given to satisfy external references. You can
specify either C or C++ source files when building executables. You
can specify both C and C++ source files at the same time as long as
the C files are C++ compatible, and you specify the -lang cpp option
(see the -lang option below).

MBUILD uses an options file to specify variables and values that are
passed as arguments to the compiler, linker, and other tools (e.g.
the resource linker on Windows). Command line options to MBUILD may
supplement or override contents of the options file, or they may
control other aspects of MBUILD's behavior. For more information see
the "Options File Details" section below.

The -setup option causes MBUILD to search for installed compilers and
allows you to choose an options file as the default for future
invocations of MBUILD.
For a list of compilers supported with this release, refer to:
http://www.mathworks.com/support/compilers/current_release/
Command Line Options Available on All Platforms:
-<arch>
Build an output file for architecture <arch>. To determine the
value for <arch>, type "computer('arch')" at the MATLAB Command
Prompt on the target machine. Note: Valid values for <arch>
depend on the architecture of the build platform.
-c
Compile only. Creates an object file but not an executable.
-D<name>
Define a symbol name to the C preprocessor. Equivalent to a
"#define <name>" directive in the source. Do not add a space after
this switch.
-D<name>=<value>
Define a symbol name and value to the C preprocessor. Equivalent
to a "#define <name> <value>" directive in the source. Do not add a
space after this switch.
-f <optionsfile>
Specify location and name of options file to use. Overrides
MBUILD's default options file search mechanism.
-g
Create an executable containing additional symbolic information
for use in debugging. This option disables MBUILD's default
behavior of optimizing built object code (see the -O option).
-h[elp]
Print this message.
-I<pathname>
Add <pathname> to the list of directories to search for #include
files. Do not add a space after this switch.
-inline
Inline matrix accessor functions (mx*). This option is deprecated
and will be removed in a future release. The executable generated
may not be compatible with future versions of MATLAB.
-l<name>
Link with object library. On Windows, name expands to
"<name>.lib" or "lib<name>.lib" and on UNIX, to
"lib<name>.LIBEXT", where LIBEXT is platform dependent. Do not
add a space after this switch.
-L<directory>
Add <directory> to the list of directories to search for
libraries specified with the -l option. On UNIX systems, you
must also set the run-time library path. Do not add a space
after this switch.
-lang <language>
Specify compiler language. <language> can be c or cpp. By
default, MBUILD determines which compiler (C or C++) to use by
inspecting the source file's extension. This option overrides
that default.
-n
No execute mode. Print out any commands that MBUILD would
otherwise have executed, but do not actually execute any of them.
-O
Optimize the object code. Optimization is enabled by default and
by including this option on the command line. If the -g option
appears without the -O option, optimization is disabled.
-outdir <dirname>
Place all output files in directory <dirname>.
-output <resultname>
Create an executable named <resultname>. An appropriate file
extension is automatically appended. Overrides MBUILD's default
executable-naming mechanism.
-setup
Specify the compiler options file to use when calling the mex
function. When this option is specified, no other command line
input is accepted.
-U<name>
Remove any initial definition of the C preprocessor symbol
<name>. (Inverse of the -D option.) Do not add a space after this
switch.
-v
Verbose mode. Print the values for important internal variables
after the options file is processed and all command line
arguments are considered. Prints each compile step and final link
step fully evaluated.
<name>=<value>
Override an options file variable for variable <name>.
This option is processed after the options file is processed
and all command line arguments are considered. See the
"Override Option Details" section below for more details.
Command Line Options Available Only on Windows Platforms:
@<rspfile>
Include contents of the text file <rspfile> as command line
arguments to MBUILD.
-regsvr
Use the regsvr32 program to register the resulting shared library
at the end of compilation. MATLAB Compiler uses this option
whenever it produces a COM or .NET wrapper file.
-reglibs
This flag registers the COM libraries included with MATLAB Builder
EX and MATLAB Builder NE. It can only be used in
conjunction with -setup.
Shared Libraries and Exports Files:
MBUILD can also create shared libraries from C source code. If a file
or files with the extension ".exports" are passed to MBUILD, it
builds a shared library. The .exports file must be a flat text file,
with each line containing either an exported symbol name, or starting
with a # or * in the first column (in which case it is treated as a
comment line). If multiple .exports files are specified, all symbol
names in all specified .exports files are exported.
Options File Details:
There are template options files for the compilers that are
supported by MBUILD. These templates are located at
[matlabroot '\bin\win32\mbuildopts'] or
[matlabroot '\bin\win64\mbuildopts'] on Windows, or
[matlabroot '/bin'] on UNIX.

These template options files are used by the -setup option to define
the selected default options file.
Override Option Details:
Use the name=value command-line argument to override a variable
specified in the options file at the command line. When using this
option, you may need to use the shell's quoting syntax to protect
characters such as spaces, which have a meaning in the shell syntax.
On Windows platforms, at either the MATLAB prompt or the DOS prompt,
use double quotes ("):
mbuild -v COMPFLAGS="$COMPFLAGS -Wall" ...
LINKFLAGS="$LINKFLAGS /VERBOSE" filename.c
At the MATLAB command line on UNIX platforms, use double quotes (").
Use the backslash (\) escape character before the dollar sign ($).
mbuild -v CFLAGS="\$CFLAGS -Wall" LDFLAGS="\$LDFLAGS -w" filename.c
At the shell command line on UNIX platforms, use single quotes ('):
mbuild -v CFLAGS='$CFLAGS -Wall' LDFLAGS='$LDFLAGS -w' filename.c
Examples:
The following command compiles "yprime.c", building an executable:

mbuild yprime.c

When debugging, it is often useful to use "verbose" mode as well
as include symbolic debugging information:

mbuild -v -g yprime.c
See also COMPUTER, MCC, PREFDIR

Potrebbero piacerti anche