External Code Integration

How to call external code from MATLAB® code

Classes

coder.ExternalDependency Interface to external code
coder.BuildConfig Build context during code generation

Functions

coder.ceval Call external C/C++ function
coder.cinclude Include header file in generated code
coder.opaque Declare variable in generated code
coder.updateBuildInfo Update build information object RTW.BuildInfo

Examples and How To

Encapsulate Interface to an External C Library

Encapsulate the interface to an external C library with coder.ExternalDependency.

Specify External File Locations

Integrate external source code, header files, and libraries with C/C++ code generated from your MATLAB code.

Call External Functions Encapsulated by coder.ExternalDependency

Call functions defined by a coder.ExternalDependency method.

Call External Functions with coder.ceval

Follow workflow and best practices for calling external functions.

Return Multiple Values from C Functions

Use coder.ref and coder.wref to return multiple values from C functions.

Update Build Information from MATLAB code

Control aspects of the build process after code generation but before compilation.

Concepts

External Code Integration for Code Generation

Integrate external code with MATLAB code intended for code generation.

Encapsulating the Interface to External Code

Encapsulate the interface to external code with coder.ExternalDependency.

External Function Calls from Generated Code

The code generator provides a programming interface for calling external functions from generated code.

Best Practices for Using coder.ExternalDependency

Use coder.ExternalDependency according to best practices.

How MATLAB Coder Infers C/C++ Data Types

The code generator maps MATLAB types to C/C++ types based on class, size, and complexity.

Was this topic helpful?