Main Content

Control Build Process Compiling and Linking

After generating code for a model, the build process determines whether to compile and link an executable program. Various factors guide this determination:

  • Generate code only option

    When you select this option, the code generator produces code for the model, including a makefile.

  • Generate makefile option

    When you clear this option, the code generator does not produce a makefile for the model. You must specify post code generation processing, including compilation and linking, as a user-defined command, as explained in Customize Post-Code-Generation Build Processing.

  • Makefile-only target

    The Microsoft® Visual C++® Project Makefile versions of the grt and Embedded Coder® target configurations generate a Visual C++ project makefile (model.mak). To build an executable, you must open model.mak in the Visual C++ IDE and compile and link the model code.

  • HOST template makefile variable

    The template makefile variable HOST identifies the type of system upon which your executable is intended to run. The variable can be set to one of three possible values: PC, UNIX, or ANY.

    By default, HOST is set to UNIX in template makefiles designed for use with The Open Group UNIX® platforms (such as grt_unix.tmf), and to PC in the template makefiles designed for use with development systems for the PC (such as grt_vcx64.tmf).

    If the Simulink® software is running on the same type of system as the system specified by the HOST variable, then the executable is built. Otherwise,

    • If HOST = ANY, an executable is still built. This option is useful when you want to cross-compile a program for a system other than the one that the Simulink software is running on.

    • Otherwise, processing stops after generating the model code and the makefile; the following message is displayed on the MATLAB® command line.

      ### Make will not be invoked - template makefile is for a different host