Main Content

What Types of Files Define Your Library?

To build (publish) a MATLAB® interface to a C++ library, you need:

  • One or more header or source files that contain declarations of all the functions exported by the library. You should be able to compile these files in a C++ development environment and use the functionality in C++ applications.

  • A compiled library file — .dll on Windows®, .so on Linux®, or .dylib on macOS. If the library is completely defined in the header or source files, then the library file is optional.

    The library file must be built in release mode by using with 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 does not support 32-bit libraries.

  • An import library file — .lib on Windows. If the library is compiled with a supported Microsoft® Visual Studio® compiler, then you need only the shared library .dll file.

  • A static library file — .a on Linux and macOS platforms, and on Windows if the library is compiled with a supported MinGW® compiler.

  • The C++ compiler that was used to build the C++ library.

For information about building an interface, see Steps to Publish a MATLAB Interface to a C++ Library. The first step is to generate a MATLAB library definition file depending on what types of files define your library. Your library might contain combinations of header files, CPP source files, and compiled library files.

See Also