Saif Ur Rehman
Saif Ur Rehman

Reputation: 348

Linking taking too long with /bigobj

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.

Upvotes: 1

Views: 1268

Answers (1)

KjMag
KjMag

Reputation: 2780

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.

Upvotes: 2

Related Questions