Main Content

C++ Development Environment

To integrate MATLAB® functions within C++ applications you need to set up your C++ development environment.

  • You can use the MATLAB desktop to create your deployable MATLAB functions, write C++ application code, and integrate the two. The MATLAB desktop environment can be used across platforms.

  • On Windows® systems, you can use Microsoft® Visual Studio® as your development environment.


Set Up MATLAB Desktop for C++ Development (Windows, Linux, and macOS)

  1. At the MATLAB command prompt, configure a C++ compiler for use with your C++ application by executing:

    mbuild -setup

  2. Use the MATLAB Editor to author the C++ application code.

  3. Use the mbuild function to compile and link C++ application code against deployable MATLAB functions.

    mbuild <cppApplicationSourceCode>.cpp -v                                            (MATLAB Data API)
    mbuild <cppApplicationSourceCode>.cpp <compilerSDKGeneratedLibrary>.lib -v          (mwArray API)

Set Up Microsoft Visual Studio for C++ Development (Windows Only)

  1. Create a new C++ project in Visual Studio. Select Console App if you are creating a C++ console application. Otherwise, pick the appropriate project type.

  2. Access project properties by right-clicking the project node in Solution Explorer and choosing Properties.

  3. Verify that the Platform is set to x64 in the project property page.

  4. In the left pane of the project property page, under C/C++ > General, add the following directories to the Additional Include Directories field:

    C:\Program Files\MATLAB\MATLAB Runtime\R2023a\extern\include

  5. Under Linker > General, add the following directories to the Additional Library Directories field:

    C:\Program Files\MATLAB\MATLAB Runtime\R2023a\extern\lib\win64\microsoft

  6. Under Linker > Input, add the following libraries:

    • In the Additional Dependencies field, add:


    • In the Delay Loaded Dlls field, add:


  7. Include the following header file in your C++ application code:

    #include "MatlabCppSharedLib.hpp"

Other Development Environments

In order to use other C++ development environments, you need to know which additional files and libraries to include during compilation. It is recommended that you first compile your C++ application using the mbuild function in MATLAB using the verbose mode. This will display all the information you need to include other development environments.

Location of Relevant Files



  • C:\Program Files\MATLAB\R2023a\extern\include

  • C:\Program Files\MATLAB\R2023a\extern\lib\win64\<compiler>

MATLAB Runtime

  • C:\Program Files\MATLAB\MATLAB Runtime\R2023a\extern\include

  • C:\Program Files\MATLAB\MATLAB Runtime\R2023a\extern\lib\win64\<compiler>



  • /usr/local/MATLAB/R2023a/extern/include

MATLAB Runtime

  • /usr/local/MATLAB/MATLAB_Runtime/R2023a/extern/include



  • /Applications/

MATLAB Runtime

  • /Applications/MATLAB/MATLAB_Runtime/R2023a/extern/include

See Also

Related Topics