5

I have an MSVC++ project consisting of an executable, several own static libraries and some precompiled static third party libraries. The exe uses incremental linking in order to speed up build time.

When I change a .cpp file within the executable project, compiling + linking is very quick (<10s).
However, when I change a .cpp file within one of my own libraries, the executable project appears to be doing a full link against every library it uses.
I'm not so sure anymore if it is a full link in fact, but from the "vc90.pdb not found" Linker Warnings, I can tell that it links against some external libraries which have not changed at all.

Here's an example of the project structure:

  • Precompiled third party libraries ExtLib1, ExtLib2 and ExtLib3
  • Own Library MyLib, using third party lib ExtLib1
  • Own Exe MyExe, using MyLib and ExtLib1-3

Changing a .cpp file in MyLib would then lead to MyExe being linked to MyLib, ExtLib1, ExtLib2 and ExtLib3, even if Incremental Linking is turned on.

A full link takes around 5 minutes in my project, so I'm asking: Is there any way to re-link only the changed library?

Tim Meyer
  • 12,210
  • 8
  • 64
  • 97

2 Answers2

2

This is a introduction to incremental linking. It lists situations that will cause a full link. One of them is "An object that was compiled with the /Yu /Z7 option is changed.", check if your MyLib caught it.

carter2000
  • 279
  • 1
  • 3
  • 9
  • My libraries are compiled with /Yu /Zi.. I tried disabling precompiled headers for the library (i.e. removing /Yu) but it didn't change much. Maybe the linker is in fact trying to do an incremental link but links almost anything. Will have to investigate this further tomorrow – Tim Meyer Jul 05 '12 at 15:54
1

When a static library changes there will always be a full link for the executable, at least in Visual Studio 2013, and you will probably get something like this in the output window:

2>Link:
2>  LINK : library changed; performing full link

Good news though: I did a quick test in Visual Studio 2015 and incremental linking seemed to work as expected.

Source: lots of experimentation and looking around, having had the same problem. Also, this: http://www.pcreview.co.uk/threads/incremental-linking-and-multiple-projects.1431266/ , specifically:

This is by design. We can't incrementally link when a static lib changes. That was never supported before either.

Ronald Laeremans, Visual C++ team

Edit - it's confirmed that VS 2015 has incremental linking when using static libraries: http://blogs.msdn.com/b/vcblog/archive/2014/11/12/speeding-up-the-incremental-developer-scenario-with-visual-studio-2015.aspx .

Tom
  • 511
  • 5
  • 9