Vscode with g++ compilation and debugging

Source: Internet
Author: User
Tags json
Vscode with g++ compilation and debugging compiling Debug

Programming with Vscode is not as convenient as vs. Some things need to be configured. compiling

Compile the configuration:
Tasks – Run Tasks – Configure task –others
Generate the Tasks.json file:

{
    //See https://go.microsoft.com/fwlink/? linkid=733558
    /For the documentation about the Tasks.json format
    "version": "2.0.0",
    "Tasks": [
        {
            "Label": "Echo",
            "type": "Shell", "
            Command": "Echo Hello",
            "group": {
                "kind": "Build",
                " IsDefault ": True
            }
        }
    ]
}

Modify "command": "Echo Hello", that is, modify the compile command
For compiling commands, please refer to the use of the g++ command.
such as "command": "g++-g-o a.out main.cpp" Debug

Press F5 to select the gdb C + +
Generate the Launch.json file:

{//Use IntelliSense to learn about related properties.
    Hover to view the description of an existing property.
            For more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [{ "Name": "(GDB) Launch", "type": "cppdbg", "Request": "Launch", "program": "
            Enter program name, for example ${workspacefolder}/a.out "," args ": []," stopatentry ": false, "CWD": "${workspacefolder}", "Environment": [], "externalconsole": true, "mimod  E ":" GdB "," setupcommands ": [{" description ":" Enable pretty-printing for 
            GdB "," text ":"-enable-pretty-printing "," Ignorefailures ": true} ]
        }
    ]
}

Modify:
"Program": "Enter program name, for example ${workspacefolder}/a.out"
For:
"Program": "${workspacefolder}/a.out"
Note: Only the command-line compiler parameter has-G to debug.

Press F5 again to do it:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.