I have a solution in MS VS 2010 that compiles and builds properly after a rebuild all (1). However, after I make a change to a source file and begin debugging, VS recognizes the project is out of date and builds the project (2) successfully (as expected).
The problem is that it seems VS begins debugging the project using obj/pdb/e开发者_如何转开发tc.. from (1) above instead of (2). If I break into the debugger and navigate to the module that changed in the file of interest, I'm told "the source file is different from when the module was built". Indicating I don't want to rebuild the source, I'm given the following info below: (Note that in order to get a "good" build I have to rebuild the solution (or delete vc100.pdb)).
Locating source for "file of interest". Checksum: MD5 {59 96 7d 1 9f b 33 20 63 4c 81 1d d7 c6 94 30}
Determining whether the checksum matches for the following locations: 1: "file of interest" Checksum: MD5 {61 66 43 cb d1 97 d1 d5 0 dc 9b 60 64 71 b2 b6} Checksum doesn't match. The file "file of interest" exists.
Looking in script documents for "file of interest"...
Determining whether the checksum matches for the following locations:
1: "file of interest" Checksum: MD5 {61 66 43 cb d1 97 d1 d5 0 dc 9b 60 64 71 b2 b6} Checksum doesn't match.
Looking in the projects for "file of interest".
The file was not found in a project.
Looking in directory
.
misc directories
.
The debugger will ask the user to find the file: "file of interest".
The user pressed Cancel in the Find Source dialog. The debug source files settings for the active solution have been modified so that the debugger will not ask the user to find the file: "file of interest".
The debugger could not locate the source file "file of interest".
At this point the debugger recognizes the pdb hashes are out of synch even though compiler/linker failed to recognize this earlier. Everything works correctly after a rebuild but doesn't seem to build itself correctly after a change to a source file.
It seems that a "rebuild" properly builds both vc100.pdb and debugger pdb while a "normal" build only only touches the compiler/linker vc100.pdb...but I'm not positive.
Anyone have any ideas?
Thanks,
Paul
Solution is very simple.
Just Exclude the file from the project (the one for which checksum issue occured).
Include the same file again in project
Rebuild whole project
Thast it. I hope this will resolve your problem. SAM
The problem isn't with the pdb it's that the VS isn't correctly detecting when modules should be re-compiled.
More specifically, I have a source-controlled code base that is tested via a suite of unit tests.
The unit tests are keyed off of a main file, say MainTest.cpp, which has the int main(...) function that launches all of the tests. This is just a glue file and rarely changes. The files that change often are the test classes it imports.
Now, all my test classes are "header-less" i.e. all definitions/declarations are contained within one module (such as TestClass1.cpp, TestClass2.cpp, etc...) mainly because they're just tests and I don't want the extra clutter.
The problem is that when I make changes to TestClass1.cpp and build, VS 2010 doesn't deem it necessary to re-build MainTest.cpp saying:
Skipping... (no relevant changes detected) MainTest.cpp
Apparently this is a known issue, see:
http://connect.microsoft.com/VisualStudio/feedback/details/99825/code-change-in-header-does-not-re-compile-correctly
To correctly build, I have to force VS to re-compile MainTest.cpp. As a workaround, I put a "touch MainTest.cpp" in my project's Pre-Build Event.
Some follow-up questions:
- Does MS intend to fix this? If so, have they?
- Is there a better workaround?
Excluding the file from the project and then including it again collowed by a project compile is the only solution that worked. Thanks to SAM. I am writing so as to document potential solutions and to show this suggestion was the most effective.
The following often suggested solutions did not work:
- Manually compiling all the .cpp files in the project using right click in the solution explorer.
- Touching Main.cpp (running: touch main.cpp) or any/all of project files, then rebuilding project.
- Resetting the project settings (inside tool-> Import and Export Settings) and the recompiling the project.
I`ve found how to reproduce it
if Intermediate Directory is set to something like
$(TMP)\Build\$(SolutionName) - $(Platform).$(Configuration) - $(ProjectName)\
then linker will not see changes, but if you set it to
S:\Build\$(SolutionName) - $(Platform).$(Configuration) - $(ProjectName)\
then linking will be ok
the problem is with th PDB file. make Clean on the project before rebuild it
Problem occurs because of the PDB file. Clean the project and rebuild it. Or remove the file from the project and include it again and rebuild it.
精彩评论