Troubleshooting MATLAB Interface to C++ Library Issues - MATLAB & Simulink (original) (raw)
Library Interface Does Not Exist Or Is Not Loaded
MATLAB® searches for the library interface file on the MATLAB path. The interface file for library libname
islibnameInterface._`ext`_
, where_ext
_ is the platform-specific file extension for a shared library file.
Missing or Incorrectly Installed Run-Time Libraries
A library interface is a dynamically linked module that the MATLAB interpreter loads and executes when you call a function in the library. Dynamic linking means that when you call the function, the program looks for dependent libraries. The library might use specialized run-time libraries which are not built into the MATLAB interface. The code for these libraries is not included in the interface; the libraries must be present on your computer when you call the library. The library publisher should provide information about installing dependent libraries.
To find library dependencies:
- On Windows® systems, download the Dependency Walker utility from the website https://www.dependencywalker.com.
- For Visual Studio® users, call:
dumpbin /dependents libname.dll
- On Linux® systems, use:
- On macOS systems, use:
Library Interface Does Not Contain Any Instances Of Type
To see what classes are available, see the documentation for your library. For librarylibname
, type:
In some cases, a publisher might create a library interface that does not include classes or other functionality from the original C++ library. For information about how to include missing functionality in the MATLAB interface, see How to Complete Definitions in Library Definition File.
Invalid clib
Array Element Type Name
The MATLAB name for a clib array element type includes clib
and the library name. For more information, see clibArray.
For example, for library libname
containing classMyClass
, the clib array type is:
clib.array.libname.MyClass
and the MATLAB element type is:
For fundamental C++ types, use upper camel case for the element type name. For example, if the C++ type is double
, then the clib array type is:
clib.array.libname.Double
and the MATLAB element type is:
First Letter Of Type Must Be Capitalized
When creating a clib array, MATLAB converts the names of fundamental C++ types to upper camel case.
For example, if the C++ type is signed int
, then the MATLAB clib array type for library libname
is:
clib.array.libname.SignedInt
and the element type is:
For strings, if the C++ type is std::string
, then:
clib.array.libname.std.String % clib array type clib.libname.std.String % element type
Access Violation When Calling Library Function
The library file must be built in release mode, using a C++ compiler that MATLAB supports. If you build the library in debug mode, it might be incompatible with MATLAB, resulting in a termination of the program.
MATLAB Interface to C++ Library Compatibility
An interface file that was published with an earlier version of MATLAB usually runs on later versions of MATLAB. If the interface generates errors, republish the interface with the current MATLAB release.
Running an interface published with a newer version of MATLAB on an older version of MATLAB is not supported.