{"id":20535,"date":"2024-11-19T16:19:13","date_gmt":"2024-11-19T08:19:13","guid":{"rendered":"https:\/\/fwq.ai\/blog\/20535\/"},"modified":"2024-11-19T16:19:13","modified_gmt":"2024-11-19T08:19:13","slug":"vscode%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cc%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/20535\/","title":{"rendered":"vscode\u5982\u4f55\u8fd0\u884cc++\u4ee3\u7801"},"content":{"rendered":"<blockquote><p>\n  \u8981\u5728 vscode \u4e2d\u8fd0\u884c c++ \u4ee3\u7801\uff1a\u5b89\u88c5 c++ \u6269\u5c55\u3002\u914d\u7f6e cmake\uff1a\u521b\u5efa cmakelists.txt \u6587\u4ef6\u5e76\u6dfb\u52a0\u76f8\u5e94\u5185\u5bb9\u3002\u521b\u5efa\u6e90\u6587\u4ef6\uff1a\u5728 main.cpp \u6587\u4ef6\u4e2d\u8f93\u5165 c++ \u4ee3\u7801\u3002\u914d\u7f6e\u4efb\u52a1\uff1a\u8bbe\u7f6e cmake \u6784\u5efa\u7cfb\u7edf\u4e3a ninja\u3002\u8fd0\u884c\u4ee3\u7801\uff1a\u6309 f5 \u6216\u5355\u51fb &#8220;\u8fd0\u884c&#8221; \u89c6\u56fe\u4e2d\u7684 &#8220;\u8fd0\u884c&#8221; \u6309\u94ae\u3002\u8c03\u8bd5\u4ee3\u7801\uff1a\u8bbe\u7f6e\u65ad\u70b9\u5e76\u6309 f5 \u6216\u5355\u51fb &#8220;\u8c03\u8bd5&#8221; \u6309\u94ae\u8fdb\u5165\u8c03\u8bd5\u6a21\u5f0f\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/03\/2024040304242027126.jpg\" class=\"aligncenter\" title=\"vscode\u5982\u4f55\u8fd0\u884cc++\u4ee3\u7801\u63d2\u56fe\" alt=\"vscode\u5982\u4f55\u8fd0\u884cc++\u4ee3\u7801\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 VSCode \u4e2d\u8fd0\u884c C++ \u4ee3\u7801<\/strong><\/p>\n<p>\u8981\u5728 VSCode \u4e2d\u8fd0\u884c C++ \u4ee3\u7801\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<p><strong>\u5b89\u88c5 C++ \u6269\u5c55<\/strong><\/p>\n<ol>\n<li>\u542f\u52a8 VSCode \u5e76\u6253\u5f00\u6269\u5c55\u89c6\u56fe\uff08Ctrl + Shift + X\uff09\u3002<\/li>\n<li>\u5728\u641c\u7d22\u680f\u4e2d\u8f93\u5165 &#8220;C++&#8221;\u3002<\/li>\n<li>\u4ece\u641c\u7d22\u7ed3\u679c\u4e2d\u5b89\u88c5 &#8220;C++&#8221; \u6269\u5c55\u3002<\/li>\n<\/ol>\n<p><strong>\u914d\u7f6e CMake<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a &#8220;CMakeLists.txt&#8221; \u7684\u6587\u4ef6\u5e76\u5c06\u5176\u4fdd\u5b58\u5728\u9879\u76ee\u76ee\u5f55\u7684\u6839\u76ee\u5f55\u4e2d\u3002<\/li>\n<li>\u5728\u8be5\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/li>\n<\/ol>\n<pre>cmake_minimum_required(VERSION 3.18)\nproject(your_project)\n\nadd_executable(your_program main.cpp)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u521b\u5efa\u6e90\u6587\u4ef6<\/strong><\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a &#8220;main.cpp&#8221; \u7684\u6587\u4ef6\u5e76\u5c06\u5176\u4fdd\u5b58\u5728\u9879\u76ee\u76ee\u5f55\u7684\u6839\u76ee\u5f55\u4e2d\u3002<\/li>\n<li>\u5728\u8be5\u6587\u4ef6\u4e2d\u6dfb\u52a0\u60a8\u7684 C++ \u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p><strong>\u914d\u7f6e\u4efb\u52a1<\/strong><\/p>\n<ol>\n<li>\u5355\u51fb VSCode \u5e95\u90e8\u7684 &#8220;\u8fd0\u884c&#8221; \u89c6\u56fe\u3002<\/li>\n<li>\u5355\u51fb\u9f7f\u8f6e\u56fe\u6807\u5e76\u9009\u62e9 &#8220;\u914d\u7f6e\u4efb\u52a1&#8221;\u3002<\/li>\n<li>\u5728 &#8220;\u4efb\u52a1&#8221; \u9009\u9879\u5361\u4e2d\uff0c\u5355\u51fb &#8220;\u521b\u5efa\u4efb\u52a1&#8221; \u6309\u94ae\u3002<\/li>\n<li>\u4e3a\u4efb\u52a1\u9009\u62e9 &#8220;CMake&#8221;\u3002<\/li>\n<li>\u5c06 &#8220;CMake \u6784\u5efa\u7cfb\u7edf&#8221; \u8bbe\u7f6e\u4e3a &#8220;Ninja&#8221;\u3002<\/li>\n<li>\u4fdd\u7559\u5176\u4ed6\u9009\u9879\u4e3a\u9ed8\u8ba4\u503c\u3002<\/li>\n<\/ol>\n<p><strong>\u8fd0\u884c\u4ee3\u7801<\/strong><\/p>\n<ol>\n<li>\u786e\u4fdd &#8220;main.cpp&#8221; \u6587\u4ef6\u5df2\u6253\u5f00\u3002<\/li>\n<li>\u6309 F5 \u6216\u5355\u51fb &#8220;\u8fd0\u884c&#8221; \u89c6\u56fe\u4e2d\u7684 &#8220;\u8fd0\u884c&#8221; \u6309\u94ae\u3002<\/li>\n<li>VSCode \u5c06\u7f16\u8bd1\u548c\u8fd0\u884c\u60a8\u7684 C++ \u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p><strong>\u8c03\u8bd5\u4ee3\u7801<\/strong><\/p>\n<ol>\n<li>\u8bbe\u7f6e\u65ad\u70b9\u4ee5\u5728\u7279\u5b9a\u884c\u505c\u6b62\u6267\u884c\u3002<\/li>\n<li>\u6309 F5 \u6216\u5355\u51fb &#8220;\u8fd0\u884c&#8221; \u89c6\u56fe\u4e2d\u7684 &#8220;\u8c03\u8bd5&#8221; \u6309\u94ae\u3002<\/li>\n<li>VSCode \u5c06\u8fdb\u5165\u8c03\u8bd5\u6a21\u5f0f\uff0c\u5141\u8bb8\u60a8\u9010\u6b65\u6267\u884c\u4ee3\u7801\u3001\u68c0\u67e5\u53d8\u91cf\u548c\u8bbe\u7f6e\u76d1\u89c6\u70b9\u3002<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u8fd0\u884cc++\u4ee3\u7801\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>\u8981\u5728 vscode \u4e2d\u8fd0\u884c c++ \u4ee3\u7801\uff1a\u5b89\u88c5 c++ \u6269\u5c55\u3002\u914d\u7f6e cmake\uff1a\u521b\u5efa cmakelists.txt \u6587\u4ef6\u5e76\u6dfb\u52a0\u76f8\u5e94\u5185\u5bb9\u3002\u521b\u5efa\u6e90\u6587\u4ef6\uff1a\u5728 main.cpp \u6587\u4ef6\u4e2d\u8f93\u5165 c++ \u4ee3\u7801\u3002\u914d\u7f6e\u4efb\u52a1\uff1a\u8bbe\u7f6e cmake \u6784\u5efa\u7cfb\u7edf\u4e3a ninja\u3002\u8fd0\u884c\u4ee3\u7801\uff1a\u6309 f5 \u6216\u5355\u51fb &#8220;\u8fd0\u884c&#8221; \u89c6\u56fe\u4e2d\u7684 &#8220;\u8fd0\u884c&#8221; \u6309\u94ae\u3002\u8c03\u8bd5\u4ee3\u7801\uff1a\u8bbe\u7f6e\u65ad\u70b9\u5e76\u6309 f5 \u6216\u5355\u51fb &#8220;\u8c03\u8bd5&#8221; \u6309\u94ae\u8fdb\u5165\u8c03\u8bd5\u6a21\u5f0f\u3002 \u5982\u4f55\u5728 VSCode \u4e2d\u8fd0\u884c C++ \u4ee3\u7801 \u8981\u5728 VSCode \u4e2d\u8fd0\u884c C++ \u4ee3\u7801\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a \u5b89\u88c5 C++ \u6269\u5c55 \u542f\u52a8 VSCode \u5e76\u6253\u5f00\u6269\u5c55\u89c6\u56fe\uff08Ctrl + Shift + X\uff09\u3002 \u5728\u641c\u7d22\u680f\u4e2d\u8f93\u5165 &#8220;C++&#8221;\u3002 \u4ece\u641c\u7d22\u7ed3\u679c\u4e2d\u5b89\u88c5 &#8220;C++&#8221; \u6269\u5c55\u3002 \u914d\u7f6e CMake \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b [&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-20535","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20535","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=20535"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/20535\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=20535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=20535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=20535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}