nolegs
nolegs

Reputation: 608

VS 2012 Does Not Build Dependent Project

I have two C++ projects in Visual Studio 2012 (Version 11.0.50727.1). Project B depends on project A, via Project Properties > Common Properties > Framework and References.

When I do a rebuild on B, the lib for project A doesn't get generated in the output directory, so B fails. The logs show that A is being built successfully, but the lib simply doesn't show up.

The really strange part is that when I do a 'clean then build' instead of 'rebuild,' everything works correctly. Similarly, project A builds fine on its own and generates a .lib. Unfortunately, the build system I have to use will be doing a 'rebuild,' and I would rather not change that if possible.

What I've Tried

I removed the framework reference and tried to add the lib as a linker dependency in B. In this case, A still failed to build, so I ended up with a missing reference.

I've searched on SO and google for a while, but have come up short so far.

Please let me know if you've ever run into something similar!

Upvotes: 0

Views: 530

Answers (1)

nolegs
nolegs

Reputation: 608

Looks like the problem was that A and B shared an intermediate directory. Making the two distinct seems to have fixed the issue.

Here's my guess as to what's happening:

  1. A gets built correctly.
  2. B starts building by doing "clean"
  3. The contents of the intermediate directory are used to determine which files need to be cleaned out of output dir, so A.lib is incorrectly removed
  4. A.lib not found

This worked in previous version of VS because we did not have parallel building of projects enabled before, so I'm assuming all projects were first cleaned, then built.

Upvotes: 1

Related Questions