Visual Studio Code
Visual Studio Code (VS Code for short) is a popular cross-platform IDE that supports C projects and has a rich set of extensions.
This guide describes the process of setting up VS Code for Zephyr’s Blinky sample in VS Code.
The instructions have been tested on Linux, but the steps should be the same for macOS and Windows, just make sure to adjust the paths if needed.
Get VS Code
Download VS Code and install it.
Install the required extensions through the Extensions marketplace in the left panel. Search for the C/C++ Extension Pack and install it.
Initialize a new workspace
This guide gives details on how to configure the Blinky sample application, but the instructions would be similar for any Zephyr project and workspace layout.
Before you start, make sure you have a working Zephyr development environment, as per the instructions in the Getting Started Guide.
Open the project in VS Code
In VS Code, select
from the main menu.Navigate to your Zephyr workspace and select it (i.e. the
zephyrproject
folder in your HOME directory if you have followed the Getting Started instructions).If prompted, enable workspace trust.
Generate compile commands
In order to support code navigation and linting capabilities, you must compile your project once to
generate the compile_commands.json
file that will provide the C/C++ extension with the
required information (ex. include paths):
west build -b native_sim/native/64 samples/basic/blinky
Configure the C/C++ extension
You’ll now need to point to the generated compile_commands.json
file to enable linting and
code navigation in VS Code.
Go to the
in the VS Code top menu.Search for the parameter C_Cpp > Default: Compile Commands and set its value to:
zephyr/build/compile_commands.json
.Linting errors in the code should now be resolved, and you should be able to navigate through the code.
Additional resources
There are many other extensions that can be useful when working with Zephyr and VS Code. While this guide does not cover them yet, you may refer to their documentation to set them up:
Contribution tooling
Documentation languages extensions
IDE extensions
Additional guides
Note
Please be aware that these extensions might not all have the same level of quality and maintenance.