1.8.08

Incremental Link

I saw someone at dotnet forum asking for a help on building a very simple application.

He said that when he built the project, he encountered an error on something that has to be related with msvcr90d.dll.

And then the story continues to Incremental Link...

 

I think it's better for me to explain a bit about incremental link (/INCREMENTAL).

This option has nothing to do with the run-time library. It's just a smart mechanism to aid us as a programmer.

Before that it's also important to know the "flow" in order to produce the EXE. Basically there're 2 steps, compiling and linking.

When you compile a source file (C source file for example), you're going to generate an object file. That object file(s) will be linked together, and voila.. you have your EXE.

You see, compile -> link -> exe.

Imagine you have a huge project (ballistic missile control project) that contains hundreds (or maybe thousand) of source file. When you change 1 source file you have to build the whole project. Compiling and then linking those hundreds object files. What this means?

Total waste of time.

 

And this is how incremental link works. You don't have to build the whole project, and waste your precious time.

When you activate this option, you'll see an ilk file. I would say this is a database which contains information about your project. For example timestamps of every object file you generated before. So when you change one file, and you generate object file, that (only) changed object file will be "patched" to a previously exe.

 

Let's experiment this, and compare the time needed to build the project. See the difference?

But, yes there's a but :)

1. Your application will be fatter (in my case 1.78 MB vs 1.43 MB)

2. May contain jump thunks*

 

Also, there's an important note from the MSDN:

To ensure that your final release build does not contain padding or thunks, link your program nonincrementally.

 

If you want to know more about code and data padding or thunks, check this website:

http://msdn.microsoft.com/en-us/library/4khtbfyf(VS.80).aspx

or this:

http://docs.sun.com/source/806-3567/ild.html

 

Back to the problem with our very simple application problem. I would say the problem is in the run-time library. He needs to make sure which library he wants to link. When he said there's an error with msvcr90d.dll. He must have linked the application with msvcrtd.lib. And this is the multithreaded and dynamic link (debug) version.

Make sure this with project's settings.

1.  C/C++ -> Code Generation -> Runtime Library

2. Linker -> Input

No comments: