I've been looking at some online resources on how can I compile a C++ project using Visual Studio Code. I'm very new to Visual Studio Code but I could not find a tutorial that clearly explains how I can compile a large C++ project that requires CMake with some arguments to enable debugging in a Unix-based operating systems like Ubuntu. The closest thing I found was this which seems pretty concise, which might be enough for more expert users. So I wonder, can someone give some step-by-step instructions on how I should set up VSCode and compile C++ code and enable debugging with GDB?
FYI, I have installed the C++ and CMake extensions.
As far as I know, you do not have any compiler attached to Visual Studio Code. You might be able to attach the terminal to it and run commands there to compile the code.
https://code.visualstudio.com/docs/editor/integrated-terminal
For debugging, try searching for C++ debugger extension in their market place.
https://code.visualstudio.com/docs/editor/debugging
Visual studio Code, Atom, etc. are text editors. You can't compile things on them right off the bat. You'll need to install some plugins/extensions/packages to do that.
https://marketplace.visualstudio.com/items?itemName=brapifra.c-compiler
If you don't want to install plugins on your editor then you can use the terminal to compile and run your code. For this you'll need to install a compiler on your computer.
Cheers!
I use vscode on my Linux system with the CMake Tools and the CMake Tools Helper plugins.
You can select on the bottom status bar in Debug/Release/MinSizedRel/RelWithDebInfo variations without further configuration.
Selecting the debug icon on the left and clicking on the gear icon on the top allows you to create debug build jobs. This requires editing a json file, but the entries are pretty self evident. This allows you to run programs with arguments for debugging purposes in the Debug console, with or without running a debugger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With