External Code Integration
When you have external code, custom code, or legacy code developed in C/C++, you can integrate it directly into your MATLAB code. To call C/C++ functions, use thecoder.ceval
function. To pass data types to or from the external code that are not definable in MATLAB code, such as pointer types,FILE
types for external file I/O, or other types, usecoder.opaque
. Configure your build to include and link to external source files, header files, object files, and libraries by usingcoder.updateBuildInfo
. To provide an object-oriented interface to an external C library, package your function calls into a class derived fromcoder.ExternalDependency
.
Classes
coder.ExternalDependency |
Interface to external code |
coder.BuildConfig |
Build context during code generation |
Functions
coder.ceval |
Call external C/C++ function |
coder.ref |
Indicate data to pass by reference |
coder.rref |
Indicate read-only data to pass by reference |
coder.wref |
Indicate write-only data to pass by reference |
coder.cinclude |
Include header file in generated code |
coder.opaque |
Declare variable in generated code |
coder.reservedName |
Generate code that does not use specified identifier names |
coder.updateBuildInfo |
Update build information objectRTW.BuildInfo |
Topics
Call C/C++ Code from MATLAB Code
Integrate C/C++ code with MATLAB code intended for code generation.
Configure Build for External C/C++ Code
Specify source files and build parameters for external C/C++ code.
Develop Interface for External C/C++ Code
Access your external code using a class interface.
Mapping MATLAB Types to Types in Generated Code
Understand how the code generator maps MATLAB data types to data types in the generated C/C++ code.
Integrate Multiple Generated C++ Code Projects
Integrate the generated C++ code from two projects into a single larger project.
Troubleshooting
Unknown Output Type for coder.ceval
Define the output type for external C/C++ function calls.