Penalty of the MSVS compiler flag /bigobj

lrineau picture lrineau · Feb 27, 2013 · Viewed 16k times · Source

The basic Google search bigobj issue shows that a lot of people are experiencing the Fatal Error C1128: "number of sections exceeded object file format limit : compile with /bigobj". The error has more chance to occur if one heavily uses a library of C++ templates, like Boost libraries or CGAL libraries.

That error is strange, because it gives the solution to itself: set the compiler flag /bigobj!

So here is my question: why is not that flag set by default? There must be a penalty of using that flag, otherwise it would be set by default. That penalty is not documented in MSDN. Does anybody have a clue?

I ask the question because I wonder if the configuration system of CGAL should not set /bigobj by default.

Answer

Frédéric Hamidi picture Frédéric Hamidi · Feb 27, 2013

The documentation does mention an important drawback to /bigobj:

Linkers that shipped prior to Visual C++ 2005 cannot read .obj files that were produced with /bigobj.

So, setting this option by default would restrict the number of linkers that can consume the resulting object files. Better to activate it on a need-to basis.