{"id":1146,"date":"2019-11-22T23:10:46","date_gmt":"2019-11-22T23:10:46","guid":{"rendered":"http:\/\/blog.davcloud.top\/?p=1146"},"modified":"2020-06-11T16:43:58","modified_gmt":"2020-06-11T16:43:58","slug":"ubuntu%e4%b8%8b%e7%94%a8visual-studio-code%e7%bc%96%e8%af%91%e5%b9%b6%e8%b0%83%e8%af%95c%e5%b7%a5%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/blog.davcloud.top\/?p=1146&lang=zh","title":{"rendered":"Ubuntu\u4e0b\u7528Visual Studio Code\u7f16\u8bd1\u5e76\u8c03\u8bd5C++\u5de5\u7a0b"},"content":{"rendered":"\n<h2>\u6458\u8981<\/h2>\n\n\n\n<p>\u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u8bb0\u5f55\u5982\u4f55\u5728Ubuntu\u4e0b\u7528Visual Studio Code\u7f16\u8bd1\u5e76\u8c03\u8bd5C++\u5de5\u7a0b\u3002<\/p>\n\n\n\n<h2>\u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668<\/h2>\n\n\n\n<p>\u4e3a\u4e86\u5728Ubuntu\u4e0b\u7f16\u8bd1\u5e76\u8c03\u8bd5C++\u5de5\u7a0b\uff0c\u9700\u8981\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668\u3002\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u6700\u65b0\u7248\u7684\u7f16\u8bd1\u5668\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install gcc g++<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u68c0\u67e5\u7248\u672c\u4ee5\u786e\u4fdd\u5176\u6b63\u5e38\u8fd0\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gcc --version\ng++ --version<\/code><\/pre>\n\n\n\n<h2>\u6b65\u9aa4\u4e8c\uff1a\u5b89\u88c5Visual Studio Code<\/h2>\n\n\n\n<p>\u4ece\u5b98\u7f51\u4e0b\u8f7dVisual Studio Code: <a href=\"https:\/\/code.visualstudio.com\/\">https:\/\/code.visualstudio.com\/<\/a>.<\/p>\n\n\n\n<p>\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5deb\u5b89\u88c5\u5305\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dpkg -i &lt;package name><\/code><\/pre>\n\n\n\n<h2>\u6b65\u9aa4\u4e09\uff1a\u5728VSCode\u4e2d\u5b89\u88c5C\/C++\u6269\u5c55<\/h2>\n\n\n\n<p>\u5728VSCode\u4e2d\u5b89\u88c5C\/C++\u6269\u5c55\u4ee5\u652f\u6301C\/C++\u8bed\u8a00\u73af\u5883\u3002\u70b9\u51fb\u5de6\u4fa7\u680f\u7684\u201cExtensions\u201d\u9009\u9879\uff0c\u641c\u7d22\u201cC\/C++\u201d\u4ee5\u5b89\u88c5\u6269\u5c55\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"710\" height=\"174\" src=\"https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/c-extension.png\" alt=\"\" class=\"wp-image-1153\" srcset=\"https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/c-extension.png 710w, https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/c-extension-300x74.png 300w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><\/figure><\/div>\n\n\n\n<h2>\u6b65\u9aa4\u56db\uff1a\u65b0\u5efa\u5de5\u7a0b\u6587\u4ef6\u5939\u5e76\u5728VSCode\u4e2d\u6253\u5f00<\/h2>\n\n\n\n<p>\u5047\u8bbe\u5de5\u7a0b\u6587\u4ef6\u5939\u4e3a~\/Desktop\/hello\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\/Desktop\nmkdir hello\ncd hello\n# Open the current dir in VSCode\ncode .<\/code><\/pre>\n\n\n\n<h2>\u6b65\u9aa4\u4e94\uff1a\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u65b0\u5efacpp\u6587\u4ef6<\/h2>\n\n\n\n<p>\u5728\u5de6\u4fa7\u680f&#8221;explorer&#8221;\u9009\u9879\u5361\u4e0b\u521b\u5efa&#8221;hello.cpp&#8221;\u6587\u4ef6\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video controls src=\"https:\/\/blog.davcloud.top\/wp-content\/uploads\/2019\/11\/create-cpp-file.mp4\"><\/video><\/figure>\n\n\n\n<h2>\u6b65\u9aa4\u516d\uff1a\u914d\u7f6e\u9ed8\u8ba4\u6784\u5efa\u4efb\u52a1<\/h2>\n\n\n\n<p>\u6309\u4e0b&#8221;Ctrl+Shift+P&#8221;\u5e76\u9009\u62e9&#8221;Configure default build task&#8221;\u9009\u9879\uff0c\u7136\u540e\u9009\u62e9&#8221;g++ build active file&#8221;\u9009\u9879\uff0c\u5c06\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u9ed8\u8ba4\u6784\u5efa\u4efb\u52a1&#8221;task.json&#8221;\u3002<\/p>\n\n\n\n<h2>\u6b65\u9aa4\u4e03\uff1a\u914d\u7f6e\u9ed8\u8ba4\u8fd0\u884c\u914d\u7f6e<\/h2>\n\n\n\n<p>\u6309&#8221;F5&#8243;\u5e76\u9009\u62e9&#8221;C++(GDB\/LLDB)&#8221;\u9009\u9879\uff0c\u9009\u62e9&#8221;Default configuration&#8221;\u9009\u9879\u3002<\/p>\n\n\n\n<p>\u7f16\u8f91\u751f\u6210\u7684launch.json\u6587\u4ef6\uff0c\u5e76\u66ff\u6362\u5982\u4e0b\u8bed\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"program\": \"enter program name, for example ${workspaceFolder}\/a.out\"<\/code><\/pre>\n\n\n\n<p>\u4e3a\u65b0\u7684\u8bed\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"program\": \"${workspaceFolder}\/${fileBasenameNoExtension}\"<\/code><\/pre>\n\n\n\n<p>\u5b8c\u6210\u540e\u4fdd\u5b58\u6587\u4ef6\u3002<\/p>\n\n\n\n<h2>\u6b65\u9aa4\u516b\uff1a\u7f16\u8bd1\u5e76\u8c03\u8bd5<\/h2>\n\n\n\n<p>\u5728&#8221;hello.cpp&#8221;\u4e2d\u7f16\u5199\u4ee3\u7801\uff0c\u6309\u4e0b&#8221;Ctrl+Shift+B&#8221;\u7f16\u8bd1\u5e76\u6784\u5efa\u5de5\u7a0b\uff0c\u6309\u4e0b&#8221;F5&#8243;\u8c03\u8bd5\u5de5\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981 \u8fd9\u7bc7\u6587\u7ae0\u5c06\u4f1a\u8bb0\u5f55\u5982\u4f55\u5728Ubuntu\u4e0b\u7528Visual Studio Code\u7f16\u8bd1\u5e76\u8c03\u8bd5C++\u5de5\u7a0b\u3002 \u6b65\u9aa4\u4e00\uff1a\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668 \u4e3a\u4e86\u5728Ubuntu\u4e0b\u7f16\u8bd1\u5e76\u8c03\u8bd5C++\u5de5\u7a0b\uff0c\u9700\u8981\u5b89\u88c5gcc\u548cg++\u7f16\u8bd1\u5668\u3002\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\u6700\u65b0\u7248\u7684\u7f16\u8bd1\u5668\uff1a \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u68c0\u67e5\u7248\u672c\u4ee5\u786e\u4fdd\u5176\u6b63\u5e38\u8fd0\u884c\uff1a \u6b65\u9aa4\u4e8c\uff1a\u5b89\u88c5Visual Studio Code \u4ece\u5b98\u7f51\u4e0b\u8f7dVisual Studio Code: https:\/\/code.visualstudio.com\/. \u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5deb\u5b89\u88c5\u5305\uff1a \u6b65\u9aa4\u4e09\uff1a\u5728VSCode\u4e2d\u5b89\u88c5C\/C++\u6269\u5c55 \u5728VSCode\u4e2d\u5b89\u88c5C\/C++\u6269\u5c55\u4ee5\u652f\u6301C\/C++\u8bed\u8a00\u73af\u5883\u3002\u70b9\u51fb\u5de6\u4fa7\u680f\u7684\u201cExtensions\u201d\u9009\u9879\uff0c\u641c\u7d22\u201cC\/C++\u201d\u4ee5\u5b89\u88c5\u6269\u5c55\u3002 \u6b65\u9aa4\u56db\uff1a\u65b0\u5efa\u5de5\u7a0b\u6587\u4ef6\u5939\u5e76\u5728VSCode\u4e2d\u6253\u5f00 \u5047\u8bbe\u5de5\u7a0b\u6587\u4ef6\u5939\u4e3a~\/Desktop\/hello\u3002 \u6b65\u9aa4\u4e94\uff1a\u5728\u5de5\u4f5c\u76ee\u5f55\u4e2d\u65b0\u5efacpp\u6587\u4ef6 \u5728\u5de6\u4fa7\u680f&#8221;explorer&#8221;\u9009\u9879\u5361\u4e0b\u521b\u5efa&#8221;hello.cpp&#8221;\u6587\u4ef6\uff1a \u6b65\u9aa4\u516d\uff1a\u914d\u7f6e\u9ed8\u8ba4\u6784\u5efa\u4efb\u52a1 \u6309\u4e0b&#8221;Ctrl+Shift+P&#8221;\u5e76\u9009\u62e9&#8221;Configure default build task&#8221;\u9009\u9879\uff0c\u7136\u540e\u9009\u62e9&#8221;g++ build active file&#8221;\u9009\u9879\uff0c\u5c06\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u9ed8\u8ba4\u6784\u5efa\u4efb\u52a1&#8221;task.json&#8221;\u3002 \u6b65\u9aa4\u4e03\uff1a\u914d\u7f6e\u9ed8\u8ba4\u8fd0\u884c\u914d\u7f6e \u6309&#8221;F5&#8243;\u5e76\u9009\u62e9&#8221;C++(GDB\/LLDB)&#8221;\u9009\u9879\uff0c\u9009\u62e9&#8221;Default configuration&#8221;\u9009\u9879\u3002 \u7f16\u8f91\u751f\u6210\u7684launch.json\u6587\u4ef6\uff0c\u5e76\u66ff\u6362\u5982\u4e0b\u8bed\u53e5\uff1a \u4e3a\u65b0\u7684\u8bed\u53e5\uff1a \u5b8c\u6210\u540e\u4fdd\u5b58\u6587\u4ef6\u3002 \u6b65\u9aa4\u516b\uff1a\u7f16\u8bd1\u5e76\u8c03\u8bd5 \u5728&#8221;hello.cpp&#8221;\u4e2d\u7f16\u5199\u4ee3\u7801\uff0c\u6309\u4e0b&#8221;Ctrl+Shift+B&#8221;\u7f16\u8bd1\u5e76\u6784\u5efa\u5de5\u7a0b\uff0c\u6309\u4e0b&#8221;F5&#8243;\u8c03\u8bd5\u5de5\u7a0b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[398,404,544],"tags":[430,570,572],"_links":{"self":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/1146"}],"collection":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1146"}],"version-history":[{"count":4,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/1146\/revisions"}],"predecessor-version":[{"id":1156,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=\/wp\/v2\/posts\/1146\/revisions\/1156"}],"wp:attachment":[{"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.davcloud.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}