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_vc.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
  • TGT_FCN_LIB template makefile variable

    The template makefile variable TGT_FCN_LIB specifies compiler command-line options. The line in the makefile is TGT_FCN_LIB = |>TGT_FCN_LIB<|. Use this token in a makefile conditional statement to specify a standard math library as a compiler option. Possible |>TGT_FCN_LIB<| token values are:

    ValueGenerates Calls To
    Name of custom CRLISO®/IEC 9899:1990 C (ANSI_C) standard math library
    ISO_CISO/IEC 9899:1999 C standard math library
    ISO_C++ISO/IEC 14882:2003 C++ standard math library
    GNUGNU extensions to the ISO/IEC 9899:1999 C standard math library