Deployment

C/C++ libraries and executables, integration into external applications

After you generate code, integrate the generated C/C++ code into your application as source code, static libraries, or dynamic libraries. To help you integrate the generated code into your application, MATLAB® Coder™ provides:

  • An example C main function that shows how to initialize arguments, call entry-point functions, and exchange data between the entry-point functions and the rest of your application.

  • Utility functions that you use to interact with dynamically allocated arrays. A dynamically allocated array is represented as a structure type called an emxArray.

  • Packaging of all required generated files for relocation to another project, code base, development environment, or machine.

See Using C/C++ Code That MATLAB Coder Generates.

Functions

coder.ceval Call external C/C++ function
coder.cinclude Include header file in generated code

Topics

Generating Standalone Code

Generating C/C++ Static Libraries from MATLAB Code

Generate a C/C++ static library at the command line or in the MATLAB Coder app.

Generating Standalone C/C++ Executables from MATLAB Code

Generate C/C++ executables at the command line or in the MATLAB Coder app.

Generating C/C++ Dynamically Linked Libraries from MATLAB Code

Generate a C/C++ dynamically linked library at the command line or in the MATLAB Coder app.

Using Generated Code

C Compiler Considerations for Signed Integer Overflows

For accurate results from signed integer C operations, the C compiler must preserve wrap-on-overflow behavior.

Using C/C++ Code That MATLAB Coder Generates

Package and relocate generated files, call generated library functions, integrate generated code into a C/C++ application, or build an executable function.

Call Generated C/C++ Functions

Use coder.ceval to call C/C++ functions generated from your MATLAB code.

Call a Generated C Static Library Function from C Code

In your C code, call a C library function that you generated with MATLAB Coder.

Call a C/C++ Static Library Function from MATLAB Code

In your MATLAB code, call a C library function that you generated with MATLAB Coder.

Code Generation of Matrices and Arrays

MATLAB Coder stores matrices and arrays in column-major format as a vector.

C Code Interface for Arrays

Use the programming interface for statically and dynamically allocated arrays in generated code.

Use a C Dynamic Library in a Microsoft Visual Studio Project

Create a Microsoft® Visual Studio® Win32 Console Application project that calls a dynamic library (DLL) generated by MATLAB Coder.

Example Main

Incorporate Generated Code Using an Example Main Function

MATLAB Coder generates an example main function that helps you to incorporate generated C code into your application.

Use an Example C Main in an Application

Generate and modify an example main function that you use to build a C executable program.

Structure of Generated Example C/C++ Main Function

Examine the parts of a generated example main function so that you can modify an example main for your application.

Packaging Generated Code

Package Code for Other Development Environments

Package generated files into a compressed file that you can relocate and unpack with a standard zip utility.

Troubleshooting

Troubleshoot Failures in Deployed Code

Generate code that includes run-time error detection.

Was this topic helpful?