Skip to content

Setting Up a VS Code IDE

Evan Pezent edited this page Feb 24, 2019 · 25 revisions

So far you have successfully built and installed MEL, perhaps run some of its examples, or even created your own CMake project and built it from the command line. You may be wondering now how you will actually write code. For MEL based projects, we recommend using a lightweight text editor over full blown IDEs like Visual Studio or Eclipse. While these IDEs provide a number of features which are undoubtedly useful, it's is unlikely that you will benefit from the added complexity. Furthermore, it is very easy for your projects to become tightly integrated with the IDE itself, making future migrations difficult.

We recommend using Visual Studio Code (not to be confused with Visual Studio proper). VS Code is similar to text editors like Sublime and Atom, but provides a number of features and extensions which make it well suited for small scale CMake based C++ development.

Start by downloading VS Code:

> choco install vscode    # this one may take a bit, be patient

o ahead and download the Ninja too. This will make the integrated CMake experience better later on.

> choco install ninja

Now open VS Code! We recommended watching these introductory videos before continuing here.

Required Extensions

There are three extensions you will need:

  1. C/C++ - Extension from Microsoft offering code completion, IntelliSense, debuging, etc. (documentation)
  2. CMake Tools - Extension which integrates CMake with VS Code and C/C++ extension (documentation)
  3. CMake - A simple syntax highlighter for CMake files (not strictly needed, but you'll want to have it)

You may also choose to install a new theme. Good options include Dracula Official, One Dark Pro, and Material Theme.

MEL Template Usage

The MEL template is already configured for use with VS Code and the extensions you just installed. Make a local copy of the template anywhere you like and open the folder in VS Code. The main areas of interest are:

  • CMake Tools - A sidebar badge for the extension from which you can Configure, Build, Clean, etc. your project.
  • Variant - The CMake Tools Variant currently selected. Controls what configuration options are passed to CMake. Click to choose other options. The template defines two variants by default:
    • Release
    • Debug
  • Kit - The CMake Tools Kit currently selected. Controls which compiler or toolchain CMake is told to generate files for. Click to choose other options. The template defines four kits:
    • msvc-x86 - uses MSVC 32-bit compiler
    • msvc-x64 - uses MSVC 64-bit compiler
    • nilrt-arm - uses NI LRT ARM cross compiler (for myRIO users)
    • nilrt-x64 - uses NI LRT x64 cross compiler (for cRIO users)
  • Build - Builds a selected target ([all] by default, but could be a single lib/exe if your project defines multiple targets)
  • Debug - Debugs a selected target displaying pertinent info in the Debug sidebar (you'll want to be in the Debug Variant)

Clone this wiki locally