C/C++ Code Generation

Using MATLAB® Coder™, you can generate platform-specific MEX functions, C/C++ static and dynamic libraries, and C/C++ executable programs. If you specify C++, MATLAB Coder wraps the C code into .cpp files so that you can use a C++ compiler and interface with external C++ applications. It does not generate C++ classes.

To learn how to generate...See...
C/C++ static libraries from your MATLAB codeGenerating C/C++ Static Libraries from MATLAB Code
C/C++ dynamic libraries from your MATLAB codeGenerating C/C++ Dynamically Linked Libraries from MATLAB Code
C/C++ executables from your MATLAB codeGenerating Standalone C/C++ Executables from MATLAB Code
MEX functions from your MATLAB codeGenerate MEX Functions by Using the MATLAB Coder App

If errors occur, MATLAB Coder does not generate code, but produces an error report and provides a link to this report. For more information, see Code Generation Reports.

Specify Custom Files to Build

In addition to your MATLAB file, you can specify the following types of custom files to include in the build for standalone C/C++ code generation.

File ExtensionDescription
.cCustom C file
.cppCustom C++ file
.hCustom header file
.o , .objCustom object file
.a , .lib, .so, .dylibLibrary
.tmfTemplate makefile for custom MATLAB Coder builds

Was this topic helpful?