Developing C++ inside a dev container using vscode.
At the moment I am working on an ubuntu machine with vscode installed. There is a new thing out there where your IDE can run a container that features all dev tools you want so that when you move from machine to machine you can take your dev envirnment and all the tools with you.
I want to find out how to do that for C++ so here is writeup while I do that. Step one is finding someone who did this already - you can find sites I read linked below.
Here are the steps I followed
- Get a coffee while remembering that I have all prerequisits. docker and vscode already installed. (docker, vscode, plugin for docker, plugin for Remote - Containers)
- Clone the demo repo git@github.com:microsoft/vscode-remote-try-cpp.git
- navigat to the folder and open it
vscode .
- click the lower left gren dev container icon and select
Remote-Containers: Open Folder in Container
- click the run and debug button on the left.
- profit
Summary
Especially when you have your basic tools installed. Starting up a project that was checkd in like the c++ sample is a breeze. Checking in the the .devcontainer and the .vscode folders seems imperative in order to get a smooth experience.
Introducing an error like 1++;
shows the appropriate compiler warning in the Problem section of vscode.
Autocompletion works for c++ keywords like double
, for functions in the same file, for standard libraries and that is how far my testing went for now.
cmake and python 2.7.16 are installed in the container.
Things I will look into later
Introducing a core community guideline problem like int arr[10];
does not show up as an issue.
Setting up conan (pip and conan are not installed).
Setting up testing.
Things I read while reseaching the topic: