MATLAB C/C++ Graphics Library    

Building Graphics Applications on a UNIX System

To create a stand-alone graphics application on a UNIX system, you must use the MATLAB Compiler (mcc), specifying the Compiler's Graphics Library bundle file.

Bundle files are ASCII text files that contain Compiler command line options and arguments. The MATLAB Compiler supports separate bundle files for creating C stand-alone graphics applications and C++ applications.

MATLAB Compiler's Graphics Library Bundle Files on UNIX Systems
C applications
<MATLAB>/toolbox/compiler/bundles/sgl
C++ applications
<MATLAB>/toolbox/compiler/bundles/sglcpp

For example, to convert the Lorenz application into a stand-alone application, enter these commands at the MATLAB prompt.

Note the following:

Results of Compilation

The MATLAB Compiler generates multiple C or C++ source code modules in your current working directory. These include wrapper files that contain necessary components of a stand-alone application, such as a main() entry point.

In addition, the first time you run the MATLAB Compiler to create a stand-alone graphics application, it creates a subdirectory, named /bin, in your current working directory. The Compiler puts in this directory versions of the MATLAB menu bar and toolbar figure files that are used by stand-alone graphics applications at run-time. (Stand-alone graphics applications use a special menu bar and toolbar. For more information, see Changes in Run-Time Behavior and Appearance.) Subsequently, when you run the Compiler, it checks for the existence of these files in the /bin directory and does not overwrite them if they exist.

Running a Stand-Alone Graphics Application

The Compiler creates the stand-alone graphics application as an executable program in your current working directory, giving it the same name as your M-file. You can run your stand-alone graphics application at the MATLAB prompt if you precede the executable name with a !, as shown in the example. You can also run a stand-alone application outside of the MATLAB environment. However, you must add to your path the location of the shared libraries to which your application is linked. To set your path, use the command from this table that is specific for your system.

Architecture
Command
HP700
setenv SHLIB_PATH <MATLAB>/extern/lib/hp700:<MATLAB>/bin/hp700:$SHLIB_PATH
All others
setenv LD_LIBRARY_PATH <MATLAB>/extern/lib/<ARCH>:<MATLAB>/bin/<ARCH>:$LD_LIBRARY_PATH

where:
  <MATLAB> is the MATLAB root directory.
  <ARCH> is your system architecture

To avoid having to reissue this command at the start of each login session, include it in a startup script such as ~/.cshrc or ~/.login. Use the ~/.login option, if your system supports it, because it only gets executed once.


 Building Graphics Applications on a PC Running the MATLAB Compiler Outside MATLAB