Main Content

External Code Integration

Call external code from MATLAB® code

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 the coder.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, use coder.opaque. Configure your build to include and link to external source files, header files, object files, and libraries by using coder.updateBuildInfo. To provide an object-oriented interface to an external C library, package your function calls into a class derived from coder.ExternalDependency.

클래스

coder.ExternalDependencyInterface to external code
coder.BuildConfigBuild context during code generation

함수

coder.cevalCall C/C++ function from generated code
coder.readRead data files at run time in generated code (R2023a 이후)
coder.refIndicate data to pass by reference
coder.rrefIndicate read-only data to pass by reference
coder.wrefIndicate write-only data to pass by reference
coder.writeCreate data files that the generated code reads at run time (R2023a 이후)
coder.cincludeInclude header file in generated code
coder.opaqueDeclare variable in generated code
coder.reservedNameGenerate code that does not use specified identifier names (R2020b 이후)
coder.updateBuildInfoUpdate build information object RTW.BuildInfo

도움말 항목

문제 해결

Unknown Output Type for coder.ceval

Define the output type for external C/C++ function calls.