Solution to include <bits/stdc++.h> in Visual Studio C++

R. Jin
2 min readFeb 18, 2021

Recently, I met some of students use a header file <bits/stdc++.h> in their codes. This <bits/stc++.h> is not a standard header file of GNU C++ library. So some compiler may fail to compiler source code with this header file. This happened to my compiler in Visual Studio 2019 community, I tried several other methods suggested from online forum but none of them are feasible to me except for the following solution that works for my case and looks easy and acceptable to me. Hence, I want to share the solution here in a directive and clear way.

1, Suppose you have had MinGW installed on PC, either in your C drive or D drive. Mine is installed in D drive.

2, Find and copy the folder bits. For example: my bits folder path location is the following one (you may reference on it to find yours): D:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\bits

3, Go to your .\Microsoft Visual Studio[version#]\VC\include location. Mine is as the following address: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\VS\include

4, Paste the folder bits in the above location, then restart your Visual Studio, you will see program with the head file <bits/stdc++.h> can be built by the compiler.

Additionally, for those don’t have MinGW:

  • you should write your own header file, name the file stdc++.h, and include all libraries in it
  • then go to, for example: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include, make new folder name it bits
  • then paste the header file stdc++.h in bits folder.

Hope this helps. If so, please give your applauses or comments.

I will share the solution to include <bits/stdc++.h> in VS Code soon.

--

--

R. Jin

世界が终わるまでは… #watchman@CSUF#R&D #VR/AR #ML #randomblogging #solutionsharing #opinionsonmyown