MinGW is a native Windows port of the GNU Compiler Collection (GCC). Install the latest MinGW compiler, after downloading from here. Your path should preferably be C:\MinGW. Finally, add the bin directory, C:\MinGW\bin to the System PATH.
Sublime Text is one of the most popular editors for development in general. It’s smooth and fast compared to other editors (being written in C++ helps that speed). Sublime also has tons of plugins you can find through Package Control. Download and install Sublime Text 3 from here. https://www.sublimetext.com/3
Sublime Text provides build systems to allow users to run external programs. Create a new build system for Sublime Text for setting up C++ compilation. Go to Tools > Build System > New Build System. Paste the following code in the file and save it.
{
"cmd": ["g++.exe","-std=c++17", "${file}", "-o", "${file_base_name}.exe", "&&" , "${file_base_name}.exe<inputf.in>outputf.in"],
"shell":true,
"working_dir":"$file_path",
"selector":"source.cpp"
}
This can be used for piping input from the inputf.in file, and output to the outputf.in file. Note that this uses the -std=c++17 flag to enable the latest features of C++17. If you don't want this or want to use C++14, replace this with the -std=c++14 flag.
Create three new files, file.cpp, inputf.in, and outputf.in. Select View > Layout > Columns : 3. This will create three columns in the workspace. Move the three files into the three columns. Select View > Groups > Max Columns : 2.
The windows will look like above when you are done. Write a hello world program, and test its working. Use Ctrl+B to build and execute the file.
Now we can speed up compilation time by precompiling all the header files as mentioned here, i.e. by precompiling the bits/stdc++.h header file. This can speed up compilation time by up to a factor of 12. For this, first, navigate to the stdc++.h file. This will be located at a directory similar to C:\msys64\mingw64\include\c++\10.2.0\x86_64-w64-mingw32\bits Right click while pressing Shift to open a Powershell/cmd window there. Run the command g++ -std=c++17 stdc++.h, to compile the header. Take care to use the same flags you used in your build system. Check to make sure that the stdc++.h.gch file was created in the directory.
Finally, we can take advantage of the features of Sublime Text, namely snippets and completions.
1. Install font Inconsolata(why? coz I like the font) from google fonts and go to preferences -> settings
and add these:
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.sublime-color-scheme",
"font_face": "Inconsolata",
"font_options":
[
"no_italic"
],
"font_size": 15,
"ignored_packages":
[
"Vintage"
],
"theme": "Default.sublime-theme"
}
How to do it??
goto tools -> command palette -> Open Resource -> Color Scheme - Default ->
then select your current theme, in my case Monokai.sublime-color-scheme
then the following file will open:
now you can add or modify colors and you can find color codes here