
Let’s assume that the project is located in ~/Documents/projects/TestQtApp and you want to build it in ~/Documents/projects/build-TestQtApp. I’ll show how to do it for a qmake project that uses GLib through pkg-config. Later, you’ll point VS Code towards this file and the code model will pick up the necessary configuration.
ʔīear is a tool that can monitor the execution of arbitrary build tools (like make or ninja) and generate the compile_commands.json file for you. Of course, you can go to c_cpp_properties.json and painstakingly configure your "includePath" and "defines," but that’s a lot of work - particularly if your project is large and uses multiple external libraries. You won’t be able to Ctrl+click to follow symbols you’ll get error squiggles under each unrecognized #include, an overall annoying experience. Once you open such project in VS Code, the code model will not recognize Qt and GLib’s include paths: Let’s also say that your project uses system libraries discovered by pkg-config, for example GLib. In our example, I’ll use qmake, an older build system from the Qt Framework. Imagine that, for some reason, you need to work with a C/C++ project that isn’t managed with CMake. I’ll show you how to configure it and which benefits it provides. If you use this file, VS Code IntelliSense engine will automatically pick up the correct include paths and defines. Since the October 2017 update, the VS Code C++ extension supports Compilation Database in the compile_commands.json file. Unfortunately, with build systems not supported natively by VS Code, you need to manually configure include paths and compilation definitions, for the code model to work properly. It works particularly well with CMake-based projects. As described in our previous blog posts, you can use Visual Studio Code as an IDE for C++ projects.