How does one set up the Visual Studio Code compiler/debugger to GCC?

前端 未结 7 539
野趣味
野趣味 2020-12-13 17:56

I am programming in C in Visual Studio Code, but I can\'t compile, as VSC only offers three compilers built in - Node.js, C# Mono, and Extension development. After a little

7条回答
  •  醉酒成梦
    2020-12-13 18:17

    Caution

    A friendly reminder: The following tutorial is for Linux user instead of Windows

    Tutorial

    If you want to debug your c++ code with GDB

    You can read this ( Debugging your code ) article from Visual Studio Code official website.

    Step 1: Compilation

    You need to set up task.json for compilation of your cpp file

    or simply type in the following command in the command window

    g++ -g file.cpp -o file.exe
    

    to generate a debuggable .exe file

    Step 2: Set up the launch.json file

    To enable debugging, you will need to generate a launch.json file

    follow the launch.json example or google others

    Step 3: Press (Ctrl+F5) to start compiling

    this launch.json file will launch the configuration when you press the shortcut (Ctrl+F5)

    Enjoy it!

    ps. For those who want to set up tasks.json, you can read this from vscode official (-> TypeScript Hello World)

提交回复
热议问题