MATLAB Runtime Server    

Compiling the Application (GUI)

In order for the application to work with the MATLAB Runtime Server, you must compile the application M-files into runtime P-files. A runtime P-file differs from a standard P-file in that the former is stamped with the same password that you used when executing rtsetup.

This section discusses:

Overview of Compilation

A shipping runtime application contains compiled versions of these files:

The easiest way to compile the application is to use the buildp function. This function determines which files to compile and compiles them. Thus you do not have to compile each file individually. To learn about this approach, see Compiling the Application with One Command below.

Alternatively, you can use depfun in conjunction with pcode. To learn about this approach, see Compiling Selected M-Files.

Tips for Compiling.   Here are a few tips to keep in mind when compiling M-files:

Compiling the Application with One Command

The buildp function creates P-code for an entire runtime application once you specify the key files in the application. Typically, you specify only the top-level file, though you might need to specify a small number of other files, as mentioned in the troubleshooting section below. The buildp function determines which files to compile, compiles them into runtime P-files, and places the runtime-ready files alongside their uncompiled counterparts.

The buildp command below creates P-code for a runtime application whose top-level file is matlabrt.m.

The output log is a string containing the name of a file that details the various phases of execution of buildp.

Troubleshooting After Using buildp.   For some applications, one call to buildp creates the entire set of runtime-ready files. However, for some applications, you might need to use buildp more than once to determine the best input list for buildp. Check the the log file (whose filename is the output string log) and/or the output for information and diagnostics. Here are some troubleshooting tips in case buildp either fails, indicates a potential problem, or gives incomplete results:

Compiling Selected M-Files

To compile selected M-files into runtime P-files, use the pcode command with the runtime flag. The runtime flag tells MATLAB to create a runtime P-file, instead of the standard P-file. Other flags and options can control which files are compiled and where the runtime P-files are placed, as explained below.

Use the -inplace flag with the pcode command, as follows. For the file myfile.m, type

To compile the entire application, apply depfun to the top-level M-file (matlabrt.m) and then apply pcode to the output. This is an alternative to using the buildp command as explained earlier. Here, the purpose of using depfun is to determine which M-files to compile. The commands are below.

Troubleshooting After Using pcode.   If your application uses toolbar or menu items from the MATLAB default figure window, then you need to include 'FigureMenuBar.fig' and 'FigureToolBar.fig' in your input to depfun. If your application uses GUI elements and creates .fig files, then you should include those .fig files in your input to depfun as well.

Also note that there are some circumstances in which depfun provides an incomplete list. For details, see Analyzing Functions Called by eval.

Removing P-Files

To remove all files with a .p extension on the path and in the current directory, type


  Organizing Files and Managing Startup Tasks (GUI) Testing While Emulating the Runtime Server (GUI)