Complete Guide to Install C++17 in Windows

In the Competitive Programming field C++ is one of the most used language, because of it’s huge STL(standard template library) functions, and day by day its getting updated. So here is the complete guide to install the latest version of C++(C++ 17) and also setup guide for Sublime Text and CodeBlocks.

Install C++17 Compiler(GCC 9.2)

To install C++17 compiler follow this link to download GCC 9.2 compiler. After download is completed, extract the file and save the extracted MinGw folder in C drive as shown in below images:

Setting up the path

If you are installing GCC compiler first time in your computer follow the steps below:



  1. Copy the bin folder path from MinGw file saved in C drive
  2. Go to Control Panel -> System -> Advanced System Setting -> Environment Variable -> Edit path from System variable -> new -> paste the path and save every thing.

If there is previously installed any GCC compiler then follow the same process to setup new GCC compiler path or just replace the previously existing MinGw folder with this new MinGw folder in C drive. Now, check the version of GCC installed on your computer to verify that is it successfully installed by running the below commmand in CMD:

gcc –version

It must be 9.2 if it is installed successfully.

Setup Guide for Sublime Text

In Sublime Text editor while running a C++ code it gives warning for some newly added functions of C++17 STL and due to default build setting of C++ program would not run if it has any warning. To overcome this problem we will add our custom build code for C++ program as:

{
    "cmd" : [ "g++.exe", "-std=c++17", "${file_name}", "-o",
              "${file_base_name}.exe", "&&", "start", "cmd",
              "/k", "${file_base_name}.exe" ],
    "file_regex" : "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "shell" : true,
    "working_dir" : "$file_path",
    "selector" : "source.cpp",
}

Copy the above code and create new build system (Tool -> build system -> new build system). Name it anything you want and save it with sublime-build extension. Now Go to tool -> build system and select the build file that you saved earlier, and we are done.

Now, to run your code press Ctrl + B.

Setup Guide for CodeBlocks

  1. Go to global Compiler setting -> select compiler as GNU GCC compiler
  2. Mark c++17 in compiler setting as:
  3. Switch to Toolchain executable tab -> select MinGw folder from C drive in Compiler’s Installation directory and also update all the program files from C-> MinGw -> bin folder. Below is the illustration of the same:

competitive-programming-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.