When you compile large source files that use templates intensively, you may receive the “File too big/too many sections” error. For the Visual Studio compiler you can simply use the /bigobj flag. The equivalent in mingw-w64 is the -mbig-obj flag. However, this is not a compiler flag but the GNU assembler and it should be passed to it.
You can set the assembler’s flags by using -Wa,<assembler_flags_comma_separated> in compiler for example:
g++ -g - Og -std=c++11 -m64 -Wa,-mbig-obj main.cpp
The syntax may seem strange but it is correct. Attempting to add the -mbig-obj flag directly to compiler will result in an error:
g++: error: unrecognized command line option ‘-mbig-obj’
In my experience, you need version 2.30 of GNU binutils (in version 2.25 linking can hang).