30 August 2018

Setting up Sublime Text in Windows 10 for Competitive Programming in C++

Hi, I switched from ubuntu to Windows recently and found it really tough to get some simple document stating "How to setup sublime for C++ in Windows 10". Somehow I successfully did it after so many trials and thus I have decided to document it myself.

  1. First of all you need to download MinGW compiler for windows as it doesn't come with C++ compiler like ubuntu. You can go to MinGW website and download it. I have also shared it on my google drive and you can go and download it from there. All following steps will be as per version I have shared in my drive. There may be little changes in latest versions so you can explore and figure them out. Google Drive Link for MinGW
  2. After download is successful, extract this file in one of folder e.g. I have done that in C:\ drive. Also I have named this as MinGW. So path in case of my computer is C:\MinGW
  3. Now you need to add environment variable for this. Click on start and type Environment Variable, you will get "Edit the system environments variables", click on that.
  4. Go to Advanced>Environment Variable, and click on it. You will see all environment variables present in your system. Click on New
  5. Now you need to add g++.exe path from MinGW folder. Usually that is present in bin folder under MinGW i.e. for me it is C:\MinGW\bin\g++.exe . Put this in variable value and save it.
  6. Now your windows is set up with C++ compiler. Now go to Sublime Text for further settings.
  7. Open "Tools>Build System>New Build System". 
  8. Copy and paste below content in build and save it with some name such as "my_cpp_build". Just make sure to change 'path' to your system's path. I have set it as mine PC's path.
  9. As you can see in above file. I have set input file name as 'inputf.in' and output file as 'outputf.in'. Please make sure that you have these files in folder where your cpp file is present for which you want to compile and see output giving some input. Use 'Ctrl + B' for build and run.
With above 9 steps you should be all ready for coding in C++. Please feel free to comment if you have any doubts regarding this. Happy Coding.

No comments:

Post a Comment