Bastl
Bastl

Reputation: 893

Visual Studio 2012 always compiles all source code files

I'm using Visual Studio 2012 and if I change one .cpp source file, Visual Studio 2012 always compiles all source code files.

How can I fix this? Thanks

Upvotes: 1

Views: 4551

Answers (5)

Jan
Jan

Reputation: 171

I've had this issues as well. After some research I found out that /MP was configured twice: on the one hand in C/C++ General-Tab with Option "Multi-processor Compilation" set to "Yes (/MP)" and on the other hand as Additional Option in Command Line section. Additional Options had "Inherit from parent or project defaults" active and was filled with /MP.

Removing the redundant entry /MP in Additional Options solved the issue for me.

Upvotes: 1

Greg Heilig
Greg Heilig

Reputation: 1

I am use MS Visual Studio 2012 and saw that the IDE insisted on compiling stdafx.cpp (which #included "stdafx.h") even though I commanded it to compile a totally different single .cpp file. I made sure that I had "Not Using Precompiled Headers" to make sure that the compile would not try to build stdafx.pch using stdafx.cpp and stdafx.h. Still the IDE insisted on building stdafx.cpp before compiling my other single .cpp file. Just for the heck of it, I deleted my stdafx.cpp file, and that worked. Now only my single .cpp file compiles when I use the "Build:Compile" command! This sounds like an IDE bug to me!

Upvotes: -1

Bastl
Bastl

Reputation: 893

I figured it out by myself. I'm using a HFS+ drive with Paragon (10) Windows driver for my project files. There, Visual Studio always compiles all source files. Then I moved it to a NTFS drive and everything is fine now. It compiles only the changed source files.

Upvotes: 3

jschroedl
jschroedl

Reputation: 4986

In my experience, this usually means that your project has a .h file which was added but the file no longer exists on disk. VS (msbuild really) thinks that the file is a generated file and since it's not there, a rebuild needs to happen so that the header is generated.

To find out if it's this problem, look in the header files folder in the Solution Explorer in VS and verify that each file listed really exists on disk. Sometimes VS will show the missing files with a different icon. If the file is really no-longer needed, you should remove it from the project.

Another possible cause is a bad .tlog file. These are files msbuild creates during the build to track the inputs to the build (helps detect things like .ico files listed in .rc but are not explicitly added as files in the project). If you use source control and sync outside of VS sometimes the dependency files are fooled into thinking that a dependency is not found and again assumes it's a generated file. The fix here is to recursively delete all the tlog files under your project directory (ex: del /s *.tlog ). The files are re-generated so it's perfectly safe to delete them.

Upvotes: 2

Luchian Grigore
Luchian Grigore

Reputation: 258608

Just use the Ctrl+F7 shortcut. This will compile only that file, so to observe changes you'll need to re-link the object files together (full build of that project).

Upvotes: 0

Related Questions