Is there any way to precompile the <bits/stdc++.h>
header file in ubuntu 20.04 like we can do in Windows OS so that I can execute programs faster in my Sublime text editor?
I use the FastOlympicCoding extension for fast execution, but I miss the old way of using an input-output file. I searched everywhere but didn't find any 'layman' approach to do that.
So, After having help from @TedLyngmo's answer and doing a little bit more research, I decided to answer the question myself with more clear steps.
PS: This answer will be more relatable to those who are using sublime with their custom build file and are on Linux OS (Ubuntu).
You need to find where stdc++.h header file is present, so open the terminal and use the command:
find /usr/include -name 'stdc++.h'
Output:
/usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h
Go to the above location and open the terminal there and now we are ready to precompile bits/stdc++.h header file.
Use the following command:
sudo g++ -std=c++17 stdc++.h
You'll observe stdc++.h.gch file is now created implying that precompiling is done.
PS: You need to use sudo as we need root privileges when g++ makes stdc++.h.gch file.
NOTE: Here as I was using the c++17 version in my custom build file so I mentioned c++17, you can use whatever version you are using.
It worked perfectly for me so I hope it helps you too!