MATLAB Coder Interface for Visual Studio Code Debugging

Use Visual Studio Code to view and debug C and C++ code, in combination with supported MATLAB and Simulink workflows.

234 Downloads

Updated 14 Sep 2022

MATLAB Coder Interface for Visual Studio Code Debugging
The MATLAB® Coder™ Interface for Visual Studio® Code™ Debugging support package allows you to use Visual Studio Code to view and debug C and C++ code. For example, code that you generate from MATLAB code and Simulink® models or code that you import from external libraries.
How to Install
You will need to install an extension in Visual Studio Code, by following the steps below:
  1. Download and install support package
  2. Open Visual Studio Code and navigate to the Extensions pane
  3. In the top right corner of the pane select "..." and "Install from VSIX..."
  4. Retrieve path of support package installation: matlabshared.supportpkg.getSupportPackageRoot()
  5. Navigate to the support package installation folder (from step 4) and select the VSIX file in "toolbox > targetframework > supportpackage > vscodedebug > extension > matlab-coder-interface-vscode-debugging.vsix"
Alternatively, if the code command is on your system path, you can install the extension by running this command in the MATLAB Command Window:
system("code --install-extension " + fullfile(matlabshared.supportpkg.getSupportPackageRoot(), "toolbox", "targetframework", "supportpackage", "vscodedebug", "extension", "matlab-coder-interface-vscode-debugging.vsix"))
Supported Workflows
The following workflows are supported with Visual Studio Code:
How to Uninstall
To disable Visual Studio Code as debugger for the workflows listed above, uninstall this support package.
Requirements
General
  • Visual Studio Code version 1.59.0 or above
  • Visual Studio Code command line (see documentation)
  • C/C++ extension by Microsoft®
Linux®
  • For SIL debugging, MATLAB must be started from a terminal running a bash shell.
Mac®
  • Xcode® or Command Line Tools are in default locations (/Applications/Xcode.app or /Library/Developer/CommandLineTools).
Windows®
  • For SIL debugging, a version of MinGW® newer than 8.0 must also be installed. To configure the path to the newer GDB version, run the command: target.mingw.OverrideDebuggerPathForMinGWGDB.set(pathToGDB)
Compilers and Debuggers
  • macOS®: Xcode & LLDB
  • Linux: GCC & GDB
  • Windows: MinGW GCC & MinGW GDB *
* MinGW needs to be installed separately. See MATLAB Support for MinGW-w64 C/C++ Compiler support package.
Support
If you have download or installation problems, please contact Technical Support - www.mathworks.com/contact_ts
MATLAB Release Compatibility
Created with R2022a
Compatible with R2022a to R2022b
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!