"Vscode" Ubuntu under VSC Compile run C + + program

Source: Internet
Author: User

Before I wrote some C + + programs under Ubuntu, I couldn't find a hao (kan) IDE, so we used vim or clion to write. Today found a Microsoft editor, the interface looks good, the function is also very useful.

Here are some of my installation and configuration methods:

1, official website: https://code.visualstudio.com/, because my is Ubuntu, so direct download. The Deb package is installed.

2. Note the icon in the lower left corner after entering, is to add extension

3, install the compilation and debugging plug-ins (click the plugin-install extension)

Input: Ext Install cpptools and ext install Webfreak.debug

(Plugin Description:

Https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

Https://marketplace.visualstudio.com/items?itemName=webfreak.debug

)

4, compile debugging needs to be in the folder (because these two steps to configure some information), so you want to select "Open Folder" in the tab bar, if you just open the file, do not compile debugging.

5, the rest of the steps can refer to the Vscode configuration of C + + compilation debugging environment (thanks to @jacean Wan)

Here is my configuration.

After opening the folder, write a test file, then press F5 (Compile and debug), then prompt "Select Environment", select C + + (GDB), and then pop up Launch.json, which is the configuration file for debug run. Replace the original content with the following:

{"Version": "0.2.0", "configurations": [{"Name": "Debug", "type": "GdB", "Request":   "Launch", "Target": "${FILE}.O", "CWD": "${workspaceroot}", "Prelaunchtask": "g++" C is gcc}]}

After saving, ctrl+shift+p, enter "Configure Task Run Program", carriage return, pop up a Tasks.json file, replace with the following:

{"    version": "0.1.0",    "command": "g++",    //gcc    "args": ["-G", "${file}", "-O", "${FILE}.O"],    " Problemmatcher ": {        " owner ":" CPP ",        " filelocation ": [" Relative "," ${workspaceroot} "],        " pattern ": {            " RegExp ":" ^ (. *):(\\d+):(\\d+): \\s+ (Warning|error): \\s+ (. *) $ ",            " file ": 1,            " line ": 2,            " column ": 3,            "Severity": 4,            "message": 5        }    }

Save, press F5 in the corresponding C or C + + file to compile and run

"Vscode" Ubuntu under VSC Compile run C + + program

Related Article

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.