{"id":21336,"date":"2024-11-19T10:28:43","date_gmt":"2024-11-19T02:28:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21336\/"},"modified":"2024-11-19T10:28:43","modified_gmt":"2024-11-19T02:28:43","slug":"vscode%e6%80%8e%e4%b9%88%e7%bc%96%e8%af%91","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21336\/","title":{"rendered":"vscode\u600e\u4e48\u7f16\u8bd1"},"content":{"rendered":"<blockquote><p>\n  \u5728 vscode \u4e2d\u7f16\u8bd1\u4ee3\u7801\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5\u7f16\u8bd1\u5668\u521b\u5efa\u7f16\u8bd1\u4efb\u52a1\uff0c\u4f8b\u5982\uff1a\u5bf9\u4e8e c\/c++\uff0c\u4f7f\u7528 g++ \u547d\u4ee4\u8fd0\u884c\u4efb\u52a1\uff08ctrl + shift + b\uff09\u5982\u9700\u8c03\u8bd5\uff0c\u8bbe\u7f6e\u65ad\u70b9\u5e76\u8fd0\u884c\u4efb\u52a1\uff08f5\uff09\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052710422083532.jpg\" class=\"aligncenter\" title=\"vscode\u600e\u4e48\u7f16\u8bd1\u63d2\u56fe\" alt=\"vscode\u600e\u4e48\u7f16\u8bd1\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 VSCode \u4e2d\u7f16\u8bd1<\/strong><\/p>\n<p>\u5728 VSCode \u4e2d\u7f16\u8bd1\u4ee3\u7801\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u5b89\u88c5\u7f16\u8bd1\u5668<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5\u4e0e\u4f60\u7684\u7f16\u7a0b\u8bed\u8a00\u76f8\u5339\u914d\u7684\u7f16\u8bd1\u5668\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e C\/C++\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5 MinGW \u6216 Clang\u3002<\/p>\n<p><strong>2. \u521b\u5efa\u4efb\u52a1<\/strong><\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u4f60\u9700\u8981\u521b\u5efa\u7f16\u8bd1\u4efb\u52a1\u3002\u5728 VSCode \u4e2d\uff0c\u8f6c\u5230\u201c\u4efb\u52a1\u201d-&gt;\u201c\u521b\u5efa\u4efb\u52a1\u201d\u3002\u9009\u62e9\u201c\u5176\u4ed6\u4efb\u52a1\u201d\uff0c\u7136\u540e\u5c06\u4ee5\u4e0b\u5185\u5bb9\u7c98\u8d34\u5230\u201ctasks.json\u201d\u6587\u4ef6\u4e2d\uff1a<\/p>\n<pre>{\n  \"version\": \"2.0.0\",\n  \"tasks\": [\n    {\n      \"label\": \"\u7f16\u8bd1\",\n      \"type\": \"shell\",\n      \"command\": \"g++\",  \/\/ \u6839\u636e\u4f60\u7684\u7f16\u8bd1\u5668\u66ff\u6362\u4e3a\u5b9e\u9645\u547d\u4ee4\n      \"args\": [\"-o\", \"${fileBasenameNoExtension}.exe\", \"${file}\"],\n      \"problemMatcher\": \"$gcc\"\n    }\n  ]\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u8fd0\u884c\u4efb\u52a1<\/strong><\/p>\n<p>\u521b\u5efa\u4efb\u52a1\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8f6c\u5230\u201c\u4efb\u52a1\u201d-&gt;\u201c\u8fd0\u884c\u4efb\u52a1\u201d\u6216\u6309 Ctrl + Shift + B \uff08Windows\/Linux\uff09\u6216 \u2318 + Shift + B \uff08macOS\uff09\u6765\u8fd0\u884c\u7f16\u8bd1\u4efb\u52a1\u3002<\/p>\n<p><strong>4. \u8c03\u8bd5<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u9700\u8981\u8c03\u8bd5\u4f60\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u5728 VSCode \u4e2d\u8bbe\u7f6e\u65ad\u70b9\u5e76\u5728\u8c03\u8bd5\u6a21\u5f0f\u4e0b\u8fd0\u884c\u4efb\u52a1\u3002\u8981\u8bbe\u7f6e\u65ad\u70b9\uff0c\u53ea\u9700\u70b9\u51fb\u4ee3\u7801\u884c\u5de6\u4fa7\u7684\u7a7a\u767d\u533a\u57df\u3002\u8981\u8fd0\u884c\u4efb\u52a1\uff0c\u6309 F5 \u6216\u8f6c\u5230\u201c\u8c03\u8bd5\u201d-&gt;\u201c\u542f\u52a8\u8c03\u8bd5\u201d\uff08Launch Debug\uff09\u3002<\/p>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u53ef\u4ee5\u901a\u8fc7\u8f6c\u5230\u201c\u6587\u4ef6\u201d-&gt;\u201c\u9996\u9009\u9879\u201d-&gt;\u201c\u8bbe\u7f6e\u201d\u81ea\u5b9a\u4e49 VSCode \u7684\u7f16\u8bd1\u8bbe\u7f6e\u3002<\/li>\n<li>\u5982\u679c\u4f60\u9047\u5230\uff0c\u8bf7\u68c0\u67e5\u4ee3\u7801\u662f\u5426\u5b58\u5728\u8bed\u6cd5\u9519\u8bef\u6216\u662f\u5426\u4f7f\u7528\u4e86\u6b63\u786e\u7684\u7f16\u8bd1\u5668\u3002<\/li>\n<li>\u6709\u8bb8\u591a\u5176\u4ed6\u7f16\u8bd1\u5668\u548c\u5de5\u5177\u53ef\u7528\u4e8e VSCode\u3002\u4f60\u53ef\u4ee5\u67e5\u770b\u5e02\u573a\u6216\u5728\u7ebf\u641c\u7d22\u4ee5\u627e\u5230\u9002\u7528\u4e8e\u4f60\u9700\u6c42\u7684\u7f16\u8bd1\u5668\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u7f16\u8bd1\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 vscode \u4e2d\u7f16\u8bd1\u4ee3\u7801\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5\u7f16\u8bd1\u5668\u521b\u5efa\u7f16\u8bd1\u4efb\u52a1\uff0c\u4f8b\u5982\uff1a\u5bf9\u4e8e c\/c++\uff0c\u4f7f\u7528 g++ \u547d\u4ee4\u8fd0\u884c\u4efb\u52a1\uff08ctrl + shift + b\uff09\u5982\u9700\u8c03\u8bd5\uff0c\u8bbe\u7f6e\u65ad\u70b9\u5e76\u8fd0\u884c\u4efb\u52a1\uff08f5\uff09 \u5982\u4f55\u5728 VSCode \u4e2d\u7f16\u8bd1 \u5728 VSCode \u4e2d\u7f16\u8bd1\u4ee3\u7801\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u5b89\u88c5\u7f16\u8bd1\u5668 \u9996\u5148\uff0c\u4f60\u9700\u8981\u5b89\u88c5\u4e0e\u4f60\u7684\u7f16\u7a0b\u8bed\u8a00\u76f8\u5339\u914d\u7684\u7f16\u8bd1\u5668\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e C\/C++\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5 MinGW \u6216 Clang\u3002 2. \u521b\u5efa\u4efb\u52a1 \u63a5\u4e0b\u6765\uff0c\u4f60\u9700\u8981\u521b\u5efa\u7f16\u8bd1\u4efb\u52a1\u3002\u5728 VSCode \u4e2d\uff0c\u8f6c\u5230\u201c\u4efb\u52a1\u201d-&gt;\u201c\u521b\u5efa\u4efb\u52a1\u201d\u3002\u9009\u62e9\u201c\u5176\u4ed6\u4efb\u52a1\u201d\uff0c\u7136\u540e\u5c06\u4ee5\u4e0b\u5185\u5bb9\u7c98\u8d34\u5230\u201ctasks.json\u201d\u6587\u4ef6\u4e2d\uff1a { &#8220;version&#8221;: &#8220;2.0.0&#8221;, &#8220;tasks&#8221;: [ { &#8220;label&#8221;: &#8220;\u7f16\u8bd1&#8221;, &#8220;type&#8221;: &#8220;shell&#8221;, &#8220;command&#8221;: &#8220;g++&#8221;, \/\/ \u6839\u636e\u4f60\u7684\u7f16\u8bd1\u5668\u66ff\u6362\u4e3a\u5b9e\u9645\u547d\u4ee4 &#8220;args&#8221;: [&#8220;-o&#8221;, &#8220;${fileBasenameNoExtension}.exe&#8221;, &#8220;${file}&#8221;], &#8220;problemMatcher&#8221;: &#8220;$gcc&#8221; } ] } \u767b\u5f55\u540e\u590d\u5236 3. \u8fd0\u884c\u4efb\u52a1 \u521b\u5efa\u4efb\u52a1\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8f6c\u5230\u201c\u4efb\u52a1\u201d-&gt;\u201c\u8fd0\u884c\u4efb\u52a1\u201d\u6216\u6309 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-21336","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=21336"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21336\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}