Exe performs full link when Library changes, despite incremental linking

醉酒当歌 提交于 2019-12-10 14:49:10

问题


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?


回答1:


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.




回答2:


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 .



来源:https://stackoverflow.com/questions/11344945/exe-performs-full-link-when-library-changes-despite-incremental-linking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!