Sheen Space

Unnecessary relink caused by “/DYNAMICBASE” in Visual C++ 2008

leave a comment »


I am working on a big C++ solution which includes many DLL and EXE projects. It is created before Visual C++ 2008. Now we migrate to VC 2008, and I create new DLL projects in the solution.

I find that everytime there is change in my new DLL code, no matter how trivial it is, for example, only comment change in .cpp file, all dependent projects relink. It happens on my new projects, not those existing projects. So I spent some time comparing project settings, and found the cause:

/DYNAMICBASE (Use address space layout randomization)

By default, /DYNAMICBASE is on.

This option modifies the header of an executable to indicate whether the application should be randomly rebased at load time.

Address space layout randomization is supported on Windows Vista.

There is also another technical article from MSDN blog:

Address Space Layout Randomization in Windows Vista

This is a new program security enhancement setting introduced in VC 2008. It causes compiled binary to change everytime. Switching this setting off makes problem gone.

If your solution is big and you don’t need this level of security, switch it off for all your new projects.

Advertisements

Written by Ying

14/10/2011 at 10:33

Posted in C++, Programming, Technology

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: