1

I am using Visual Studio 2012 to compile a program in debug mode. The StylesDatabase.cpp and LanguagesDatabase.cpp used to compile fine without /bigobj ... since I removed some functions and shifted some functions from protected to public.

Both the C++ files are fairly small but use templated container classes like Boost.MultiIndex(es), Boost.Unordered(_maps) and Wt::Dbo::ptrs. Wt::Dbo::ptr is a pointer to a database object and Wt::Dbo is an ORM library.

After this change, the compiler fails asks me to set /bigobj. After I set /bigobj the compiler works fine, however the linker was taking more than 30 minutes.

So my question is:

  1. How come a fairly small file can exceed the limit of Visual C++? What exactly causes the limit to be exceeded.
  2. How can I prevent the limit to be exceeded without splitting the cpp files?
  3. Why is the linker taking so much time?

I can provide the source if its necessary.

Saif Ur Rehman
  • 338
  • 3
  • 14

1 Answers1

1

Your files are not the only ones that the linker has to handle - it has to deal also with library files, and in your case these are the Boost template libraries that requires /bigobj flag. Take a look at this Microsoft page: http://msdn.microsoft.com/en-US/library/ms173499.aspx. Even if your files are small, heavily-templated libraries may require you to use /bigobj anyway.

You can think about it that way: somebody had to produce a lot of code so that you can produce much less code writing your program, but this code produced by someone else is there and has to be dealt with at some point as well.

KjMag
  • 2,650
  • 16
  • 16
  • What do u suppose I do for the extremely long linking time? – Saif Ur Rehman May 25 '14 at 09:09
  • There are many possible answers and they depend on your current configuration, which I of course do not know. There is a plenty of information about the subject, also on SO. You may want to read for example these threads: http://stackoverflow.com/questions/5030946/speed-up-compilation-link-time-when-using-boost-libraries, http://stackoverflow.com/questions/364240/how-do-you-reduce-compile-time-and-linking-time-for-visual-c-projects-nativ, http://stackoverflow.com/questions/143808/how-to-improve-link-performance-for-a-large-c-application-in-vs2005. Good luck! – KjMag May 26 '14 at 06:37