User Guide

  • 2022.2
  • 04/11/2022
  • Public Content

Developing a Visual Studio Code Project

Using Visual Studio Code* with Intel® oneAPI Toolkits
The steps below describe how to install oneAPI extensions for Visual Studio Code and use them to set up your environment, browse samples and create projects. If you prefer to watch a video presentation of how to do these tasks, see oneAPI Visual Studio Code Extensions.

Explore Samples Using Visual Studio Code*

Before working with oneAPI samples, it is recommended that you install the VS Code “Code Sample Browser for Intel oneAPI Toolkits” extension and the VS Code “Environment Configurator for Intel oneAPI Toolkits” extension.
Both can be quickly found in the VS Code extensions marketplace by typing “oneapi” into the marketplace search bar.
You may also choose to install the “Extension Pack for Intel oneAPI Toolkits”, which includes those two extensions as well as additional VS Code extensions to help you develop with oneAPI Toolkits.
The steps below describe how to use these extensions to configure the oneAPI development environment for use with VS Code and use the Sample Browser to locate and create sample projects that help you learn how to use oneAPI features.

Browse oneAPI samples using VS Code:

  1. Click on the oneAPI button on the left navigation to view samples. If you do not have the extension installed, search the Extensions Marketplace for “Sample Browser for Intel oneAPI”.
  1. A list of available samples will open in the left navigation.
  1. To view the readme for the sample, click the image3 next to the sample. If you choose to build and run the sample, the readme will also be downloaded with the sample.
  2. To build and run a sample, click the foldericon to the right of the sample name.
  3. Create a new folder for the sample. The sample will load in a new window:

Configure the oneAPI Environment

  1. Press
    ( or
    View -> Command Palette…
    ) to open the Command Palette.
  2. Type
    Intel oneAPI
    to view options of the installed extensions.
  3. Click on
    Intel oneAPI: Initialize environment variables
  4. Locate the setvars file:
    • Linux: By default,
      is located in
      for root or sudo installations, or located in
      for local user installations.
    • Windows: By default,
      is located in
      C:\Program Files(x86)\Intel\oneAPI\
    If you customized the installation folder, setvars is in your custom folder.
  5. In the case of multiple folders in workspace, select the appropriate one. All tasks, launches, and terminals created from VS Code will now contain the oneAPI environment.

Build and Run

Follow the instructions in the for the sample.
Not all oneAPI sample projects use CMake. The file for each sample specifies how to build the sample. We recommend that you check out the CMake extension for VS Code that is maintained by Microsoft.

Try Debugging (CPU and GPU Only) (Preview)

Intel® Distribution for GDB* does not currently support VS Code. You can use upstream gdb to debug.
This section assumes that you can build your sample and have installed the Microsoft VS Code C/C++ Extension. The C/C++ extension is required to configure the oneAPI C/C++ debugger.
The Intel® oneAPI Base Toolkit includes a special version of GNU* GDB (
) designed to support oneAPI C/C++ applications. To debug your DPC++ application using this special debugger, you will need to make changes to the .vscode/launch.json configuration file.
  1. Go to
    Open Configurations
    , and open the
    configuration settings.
    If you are prompted to select a debug environment, choose
    C++ (GDB/LLDB)
  1. Copy the code shown below into your launch.json file, and replace the
    property’s value with the path to your project’s executable (that is, the application that you are going to debug).
    If VS Code doesn't recognize the application name, you may have to insert the full path and file name into the ``launch.json`` file's ``"program":`` property.
  2. Add
    to your launch.json configuration’s
    application should have been added to your path when you ran to configure the oneAPI development environment, prior to starting VS Code. If you prefer, you can specify the full path and filename to the
    application in your launch.json file.
  3. In some configurations, GDB may not be compatible with VS Code. If this happens, add the environment variable to disable `gdb-oneapi` support for GPU autolaunch. This can either be done in the environment prior to launching VS Code, or within the launch.json:
    { "version":"0.2.0", "configurations":[ { "name":"(gdb) Launch", "type":"cppdbg", "request":"launch", "program":"${workspaceFolder}/build/array-transform", "args":[ "cpu" ], "stopAtEntry":false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole":false, "MIMode":"gdb", "miDebuggerPath":"gdb-oneapi", "setupCommands":[ { "description":"Enable pretty-printing for gdb", "text":"-enable-pretty-printing", "ignoreFailures":true }, { "description": "Disable target async", "text": "set target-async off", "ignoreFailures": true } ] } ] }
  4. Bring up the debug view by selecting the
    icon in the
    Activity Bar
    . You can also use the keyboard shortcut (
  5. Start the run and debug session by clicking the green
    icon, or go to
    Start Debugging

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at