{"id":2207,"date":"2022-02-27T04:45:40","date_gmt":"2022-02-26T20:45:40","guid":{"rendered":"https:\/\/guerilla.ddns.net\/wp\/?p=2207"},"modified":"2025-09-10T10:27:07","modified_gmt":"2025-09-10T02:27:07","slug":"using-c-on-linux-in-visual-studio-code","status":"publish","type":"post","link":"https:\/\/guerilla.ddns.net\/wp\/?p=2207","title":{"rendered":"Using C++ on Linux in Visual Studio Code"},"content":{"rendered":"<h1><strong>Using C++ in VS Code<\/strong><\/h1>\n<p>1. <strong>Terminal &gt; Configure Default Build Task<\/strong> to create <span style=\"color: red;\">tasks.json<\/span>.<br \/>\n&nbsp;&nbsp;&nbsp;Note: You can learn more about tasks.json variables in the <a href=\"https:\/\/code.visualstudio.com\/docs\/reference\/variables-reference\" target=\"_blank\">variables reference<\/a>.<br \/>\n&nbsp;<br \/>\n2. <strong>Run &gt; Add Configuration&#8230;<\/strong> and then choose <strong>C++ (GDB\/LLDB)<\/strong> to create <span style=\"color: red;\">launch.json<\/span>.<br \/>\n&nbsp;<br \/>\n3. <strong>C\/C++: Edit Configurations (UI)<\/strong> from the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> to create <span style=\"color: red;\">c_cpp_properties.json<\/span>.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n<strong><span style=\"font-size: 14pt;\">Build<\/span><\/strong><br \/>\nPress <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>B<\/kbd> or from the Terminal main menu choose <strong>Run Build Task<\/strong>.<br \/>\n&nbsp;<br \/>\n<strong><span style=\"font-size: 14pt;\">Start a debugging session<\/span><\/strong><br \/>\n1. Press <kbd>F5<\/kbd> or from the main menu choose <strong>Run &gt; Start Debugging<\/strong><br \/>\n&nbsp;<br \/>\n2. Press <kbd>Ctrl<\/kbd>+<kbd>F5<\/kbd> or from the main menu choose <strong>Run &gt; without Debugging<\/strong><br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<h1><strong>Using CMake Tools<\/strong><\/h1>\n<p>1. Open the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> and run the <strong>CMake: Quick Start<\/strong> command to create <span style=\"color: red;\">CMakeLists.txt<\/span>.<br \/>\n&nbsp;<br \/>\n2. Open the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> and run <strong>CMake: Select a Kit<\/strong> to select the compiler you want to use.<br \/>\n&nbsp;<br \/>\n3. Open the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> run the <strong>CMake: Select Variant<\/strong> command to select a variant.<br \/>\n&nbsp;<br \/>\n4. Open the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> and run the <strong>CMake: Configure<\/strong> command to configure your project.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n<strong><span style=\"font-size: 14pt;\">Build<\/span><\/strong><br \/>\nPress <kbd>F7<\/kbd>, or open the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> and run the <strong>CMake: Build<\/strong> command, or select the <strong>Build<\/strong> button from the Status bar.<br \/>\n&nbsp;<br \/>\n<strong><span style=\"font-size: 14pt;\">Start a debugging session<\/span><\/strong><br \/>\n1. Press <kbd>Ctrl<\/kbd>+<kbd>F5<\/kbd> or open the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> and run <strong>CMake: Debug<\/strong>.<br \/>\n&nbsp;<br \/>\n2. Press <kbd>Shift<\/kbd>+<kbd>F5<\/kbd> or open the Command Palette <kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>P<\/kbd> and run <strong>CMake: Run without Debug<\/strong>.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\nref:<br \/>\n\u2022 <a href=\"https:\/\/code.visualstudio.com\/docs\/cpp\/config-linux\" target=\"_blank\" rel=\"noopener\">Using C++ on Linux in VS Code<\/a><br \/>\n\u2022 <a href=\"https:\/\/code.visualstudio.com\/docs\/cpp\/cmake-linux\" target=\"_blank\" rel=\"noopener\">Get started with CMake Tools on Linux<\/a><br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n#c++ #linux #vscode #cmake<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using C++ in VS Code 1. Terminal &gt; Configure Default [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[212],"tags":[27,63],"class_list":["post-2207","post","type-post","status-publish","format-standard","hentry","category-coding","tag-coding","tag-linux"],"_links":{"self":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2207"}],"version-history":[{"count":16,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2207\/revisions"}],"predecessor-version":[{"id":3561,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2207\/revisions\/3561"}],"wp:attachment":[{"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guerilla.ddns.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}