Rob Walker
Rob Walker

Reputation: 47472

VS2010 always relinks the project

I am migrating a complex mixed C++/.NET solution from VS2008 to VS2010.

The upgraded solution works in VS2010, but the build system is always refereshing one C++/CLI assembly. It doesn't recompile anything, but the linker touches the file. The causes a ripple effect downstream in the build as a whole bunch of dependent then get rebuilt.

Any ideas on how to find out why it thinks it needs to relink the file? I've turned on verbose build logging, but nothing stands out.

Upvotes: 11

Views: 8996

Answers (2)

Mike Sadler
Mike Sadler

Reputation: 1808

I'm just adding this for the record, in case anyone else gets this problem in the future.

We had a similar problem with a large, mixed FORTRAN/C++ project relinking whether or not anything had changed. It seems to have started when the solution was upgraded from VS2008 to 2010, although no-one could quite remember.

Eventually, I took a serious look at it (it was annoying, but not enough to do anything). By process of elimination, I have found the solution:

Remove any quotes in the "Additional Library Directories" of the top-level FORTRAN project (i.e. the one that makes the executable).

Now, I wouldn't believe this myself without evidence, so if you have the urge to reproduce this error yourself:

  1. Open a new VS2010 session.
  2. Create a new FORTRAN project that makes an executable.
  3. Leave it empty, but link it to a non-inbuilt lib file (i.e. one of your own), and add your library's directory to the Additional Library Directories.
  4. Check this compiles and links correctly.
  5. Now try adding double quotes (") around the directory, and click on "Build" several times. If your session is like mine, then it will relink every time. When you remove the quotes, it stops.

This only appears to be a problem on the top-level project, and when those projects are FORTRAN - the quotes have no effect on C++ projects or those that create libs.

The relinking does not occur if VS does not need to search for libs (for example, if all of your libs are inbuilt, like kernel32.lib), but will occur whether or not your lib is in the directory which has quotes or a different one.

If anyone can justify this "feature", please let me know!

Upvotes: 1

Rob Walker
Rob Walker

Reputation: 47472

Turns out the problem was that the PDB filename was defined under both the compiler settings and the linker settings (with the same name).

This seemed to cause a problem in VS2010 as somehow an 'old' pdb from the intermediate directory (compiler output?) was being copied over the one in the output directory (linker output?). This resulted in the pdb in the output directory being older than some of the obj files and forcing the relink next time around (rinse and repeat).

Clearing the pdb name settings seemed to fix the problem, and the defaults were fine.

Upvotes: 8

Related Questions