MATLAB Compiler    

Preparing to Compile

Using the System Compiler

If the MATLAB Compiler and your supported C or C++ compiler are installed on your system, you are ready to create C or C++ stand-alone applications. To create a stand-alone C application, you can simply enter

This simple method works for the majority of users. Assuming filename.c contains a main function, this example uses the system's compiler as your default compiler for creating your stand-alone application. If you are a user who does not need to change C or C++ compilers, or you do not need to modify your compiler options files, you can skip ahead in this section to Verifying mbuild. If you need to know how to change the options file or select a different compiler, continue with this section.

Changing Compilers

Changing the Default Compiler.   You need to use the setup option if you want to change any options or link against different libraries. At the UNIX prompt type

The setup option creates a user-specific options file for your ANSI C or C++ compiler. Executing mbuild -setup presents a list of options files currently included in the bin subdirectory of MATLAB:

If there is more than one options file, you can select the one you want by entering its number and pressing Return. If there is only one options file available, it is automatically copied to your MATLAB directory if you do not already have an mbuild options file. If you already have an mbuild options file, you are prompted to overwrite the existing one.

Using the setup option sets your default compiler so that the new compiler is used everytime you use the mbuild script.

Modifying the Options File.   Another use of the setup option is if you want to change your options file settings. For example, if you want to make a change to the current linker settings, or you want to disable a particular set of warnings, you should use the setup option.

If you need to change the options that mbuild passes to your compiler or linker, you must first run

which copies a master options file to your local MATLAB directory, typically
$HOME/.matlab/R13/mbuildopts.sh.

If you need to see which options mbuild passes to your compiler and linker, use the verbose option, -v, as in

to generate a list of all the current compiler settings. To change the options, use an editor to make changes to your options file, which is in your local matlab directory. Your local matlab directory is a user-specific, MATLAB directory in your individual home directory that is used specifically for your individual options files. You can also embed the settings obtained from the verbose option of mbuild into an integrated development environment (IDE) or makefile that you need to maintain outside of MATLAB. Often, however, it is easier to call mbuild from your makefile. See your system documentation for information on writing makefiles.

Temporarily Changing the Compiler.   To temporarily change your C or C++ compiler, use the -f option, as in

The -f option tells the mbuild script to use the options file, <file>. If <file> is not in the current directory, then <file> must be the full pathname to the desired options file. Using the -f option tells the mbuild script to use the specified options file for the current execution of mbuild only; it does not reset the default compiler.


  Building Stand-Alone Applications on UNIX Verifying mbuild