1/6/2024 0 Comments Cmake debug buildHowever, you don’t need all of the options VSCode sets up by default. If you’ve installed all the extensions correctly, you should be able to select “C/C++: (gdb) Launch”. Specifically, you can click on the blue “add configuration” button on the bottom right. To create the launch.json file, select the “run and debug button”, and then click on “create a launch.json file”.ĭue to installing the C/C++ extensions on VSCode, you should be able to add a default debug configuration. Writing a launch.json file is necessary to tell VSCode how to debug your project: which program to run, where to find the debugger, what arguments to give your program, etc. This is the meat and potatoes of debugging in Visual Studio Code. For this reason, whether you’re using the example project mentioned in this post, or your own custom project, the instructions will achieve the same thing. It’s worth noting that the above instructions should work for any CMake project. Essentially, CMake mirrors the structure of your main project, so all executables and libraries will be where they were created in the original CMakeLists.txt files. Compile with “CMake: Build” – interestingly, once this is done you will find all your programs and libraries under the “build” directory.CMake will create the “build” directory and place all CMake files under that directory. “CMake: Configure” – select this option to configure your CMake project.Simply select the GCC option, which is the compiler we previously installed. “CMake: Select a Kit” – once you select this option, a dropdown menu of compilers will show up.Make sure to follow the instructions for each option! After pressing CTRL + SHIFT + P, search and select each of the items in the list below. Configure And Compile Your CMake Project On Visual Studio Codeįirstly, make sure you can configure and compile your CMake project on VSCode. In this section, we look at how to debug C++ application created for Linux under WSL, all within VSCode. Without further ado, let’s see how we can use VSCode to debug our C++ project. ![]() Debugging Your C++ / CMake WSL Project With VSCode If you installed all the Visual Studio Code extensions correctly, VSCode should pop up with fetch-content as your workspace. Once you downloaded the files to WSL, navigate cd into the fetch-content directory in the repository, then simply type code. Figure 1: Gif showing how to open a WSL directory as a workspace on VSCode. Therefore, if you would like to work with the same examples mentioned here, visit the link and download the project to your WSL. Opening The Test Project On VSCodeįor this example, we’re using the project created for the post about integrating Google Tests into CMake. For example, “how to install make on Manjaro” on Google may tell you to run sudo pacman -S make. However, I recommend googling “how to install X” for your Linux distribution, so you can get the right terminal command for the installation. You can similarly install the other tools in that way. For example, if you’re on Ubuntu, running sudo apt-get install gcc will install the compiler. Interestingly, each Linux distribution has a different way of installing packages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |