Documentation moved
We introduced Quickstarts as a new place for examples of how to use your favourite language and framework on Gitpod. Remember though, even if you can't find your use case as a quickstart, Gitpod very likely still supports your programming language as it's simply a Ubuntu-based operating system in the cloud. Visit the quickstarts
C++ in Gitpod
Gitpod supports C++ right out of the box, but there are still ways to enhance your C++ experience within Gitpod.
Example Repositories
Here are a few C++ example projects that are already automated with Gitpod:
Repository | Description | Try it |
---|---|---|
Component Editor | circuito.io Component Editor | |
tinyraycaster | old-school FPS in a weekend | |
HelloGitPod | Example Gitpod C++ configuration with clang-tidy linter enabled |
Environment
C++ Tools
All Gitpod workspaces come with the latest available clang
, gcc
, cmake
, gdb
, and other useful C++ tools pre-installed by default.
However, if youāre missing some additional tools, you can simply run brew install <tool_name>
to install it in the current workspace or write your own .gitpod.Dockerfile to install it across all workspaces for your repository.
IDE Features
Clangd Language Server
Gitpodās native C++ support is currently provided by Theiaās native C++ extension, which builds upon Clangd for out-of-the-box language server support on C++ source files.
More complex projects may need a build system capable of outputting a compile_commands.json
file before Clangd can work fully.
The extension can be pointed to a directory containing this file as part of a build configuration within Theiaās settings.json
:
{
"cpp.buildConfigurations": [
{
"name": "Release",
"directory": "/workspace/project/cmake/release/build"
},
{
"name": "Debug",
"directory": "/workspace/project/cmake/debug/build"
}
]
}
Debugging
Since gdb
is already pre-installed in Gitpod, you can already debug any C, C++, Go, etc. program directly from the Terminal with a single command.
However, you can also get the IDEās Debugging features to work with your C++ program, using GDB as a backend.
To enable C++ debugging for your project, simply follow these steps:
Open the Extensions panel (in the IDEās left vertical menu bar)
Use the Search feature to find the extension called āNative Debugā, then click on
Install
, and selectInstall for this project
Next, open the Debug panel (also in the IDEās left vertical menu bar), and click on the Gear (āļø) icon to open the
launch.json
configuration fileFinally, configure debugging for your project by adding a GDB launch configuration. You can use auto-completion for assistance. In the end, your
launch.json
should look something like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "launch",
"name": "Debug Firefox (GDB)",
"target": "./obj-x86_64-pc-linux-gnu/dist/bin/firefox",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText"
}
]
}
Note: This example GDB launch configuration points to a compiled Firefox browser binary. Youāll need to adjust it to point to your projectās own compiled binary.
With this, you should be able to set breakpoints in your C++ code directly from the code editor margin, then start a debugging session from the Debug panel. The IDE should then show you debug information, hopefully pause execution on your breakpoint, and allow you to step through the code.
If that doesnāt work, please feel free to ask for help in community.gitpod.io and weāll be happy to help you make debugging work for your project.