Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Generating C Code from VIs (C Generator)

LabVIEW 2011 C Generator Help

Edition Date: June 2013

Part Number: 373144C-01

»View Product Info

After you develop the VI for C code generation, customize the platform definition file, define C code generation options, and configure the exported function prototype, you can generate C code from the exported VI. In the C Code Generation build specification, click the Build button to generate C code. You also can right-click the C Code Generation build specification in the Project Explorer window and select Build from the shortcut menu to generate C code.

The LabVIEW C Generator uses the options you specify in the C Code Generation Properties dialog box to generate C code from the block diagram. The C Generator generates each VI in the VI hierarchy into a separate C file using a C function name, which is more restrictive than a VI name. Any non-alphanumeric characters become underscores. If the VI name begins with a non-alphanumeric character, the C Generator prepends A_ to the beginning of the C function name.

Use the Destination directory option on the Information page of the C Code Generation Properties dialog box to specify where to save the generated C files.

The C Generator generates the following files:

  • exportedVIname.c, where exportedVIname, is the name of the VI you want to export as a C function. This file contains the exported function. You must include this file in the linker input list.
  • exportedVInameLib.h, where exportedVIname, is the name of the VI you want to export as a C function. This file contains the library interface that specifies the generated function you defined in the Define VI Prototype dialog box. You must include this file in the external application.
  • VIname.c, where VIname is the name of a subVI in the hierarchy of the exported VI. You must include this file in the linker input list.
  • LVForms.h contains declarations for the entry point functions for each VI. This file is required for compiling the generated C files.
  • LVFuncsUsed.h contains usage information to support source-level dead-code stripping. This file is required for compiling the generated C files.
  • LVGlobs.h contains declarations for global initialization functions and data type information used in an external application. This file is required for compiling the generated C files.
  • Makefile is an example makefile. When you use the make command, the GNU Make utility reads this file. After the C Generator generates Makefile, the C Generator does not overwrite this file if you regenerate the C code. If you want to generate a new example Makefile, you must delete the file before regenerating the C code.
    Note  LabVIEW code depends on the LabVIEW run-time library, which includes support for all basic functions. You must link to the LabVIEW run-time library with all exported VIs. The LabVIEW run-time library source is located in the labview\CCodeGen\libsrc directory. You also must link to the LabVIEW analysis library if the exported VI uses math or signal processing VIs. The LabVIEW analysis library source is located in the labview\CCodeGen\analysis directory. You also must link to the LabVIEW simulation library if the exported VI uses the Simulation VIs and functions. The LabVIEW simulation library source is located in the labview\CCodeGen\simulation.
  • dependencies.mk is the secondary makefile. The C Generator includes all LabVIEW settings, such the build specification name and C code generation option values, that are required to generate C code. The C Generator updates this file if the hierarchy of the exported VI changes. LabVIEW also automatically overwrites this file during the build process.

DllMain.c, which is not created when the C Generator generates C code, is an example entry point for a DLL. This file is required for building DLLs that run on Windows. This file is located in the labview\CCodeGen\libsrc\platform\win directory.

Tip  To open the directory containing the generated C files, right-click the C Code Generation build specification in the Project Explorer window and select Explore from the shortcut menu.

Removing Generated C Code

To delete all generated *.c and *.h files in the destination directory for an exported VI, right-click the C Code Generation build specification in the Project Explorer window and select Clean from the shortcut menu. The Clean option does not delete makefiles or built libraries.


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit