MBUILD Compile an executable from C/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. 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. 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: - Build an output file for architecture . To determine the value for , type "computer('arch')" at the MATLAB Command Prompt on the target machine. Note: Valid values for depend on the architecture of the build platform. -c Compile only. Creates an object file but not an executable. -D Define a symbol name to the C preprocessor. Equivalent to a "#define " directive in the source. Do not add a space after this switch. -D= Define a symbol name and value to the C preprocessor. Equivalent to a "#define " directive in the source. Do not add a space after this switch. -f 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 Add to the list of directories to search for #include files. Do not add a space after this switch. -l Link with object library. On Windows, expands to ".lib" or "lib.lib" and on UNIX, to "lib.LIBEXT", where LIBEXT is platform dependent. Do not add a space after this switch. -L Add 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. -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 Place all output files in directory . -output Create an executable named . 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 Remove any initial definition of the C preprocessor symbol . (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. = Override an options file variable for variable . 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: @ Include contents of the text file as command line arguments to MBUILD. Options File Details: There are template options files for the compilers that are supported by MBUILD. These templates are located at [matlabroot '\bin\win32\mexopts'] or [matlabroot '\bin\win64\mexopts'] on Windows, or [matlabroot '/bin/glnxa64/mexopts'] on Linux, or [matlabroot '/bin/maci64/mexopts'] on MAC. 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 ("): 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: To compile and link an external C program foo.c against libfoo,use mbuild foo.c -L. -lfoo (on UNIX) mbuild foo.c libfoo.lib (on Windows) This assumes both foo.c and the library are in the current working folder. See also COMPUTER, MCC, PREFDIR