"I have the simplest taste. I'm always satisfied with the best" Email     Devices     Storage     Remote Workplace

MSB8027: Two or more files with the name of Texture.cpp will produce outputs to the same location.

MSB8027: Two or more files with the name of Texture.cpp will produce outputs to the same location.

Ahh the joys of working with VC++. Porting some *nix code across never goes nicely, even when there’s nothing to get cause issues. In porting a spatial augmented reality system we had 2 different Texture.cpp files (one for actual textures, the other for OBJ textures), each in different subfolders, however the VC++ compiler doesn’t overly appreciate this:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(942,5): warning MSB8027: Two or more files with the name of Texture.cpp will produce outputs to the same location. This can lead to an incorrect build result.  The files involved are src\geometry\Texture.cpp, src\graphics\Texture.cpp.

The application continues to compile, but you will almost certainly get errors when it includes the wrong file and you go to access a member of the wrong class!

This is a known issue, as the following Microsoft Connect thread shows has been an issue and was meant to be fixed in Visual Studio 2013 Update 1 (I’m using Update 3 and still now fix!):

https://connect.microsoft.com/VisualStudio/feedback/details/797460/incorrect-warning-msb8027-reported-for-files-excluded-from-build

Solution

When VC++ compiles all the files down it puts them all in the one folder and basically just overwrites the first output file with the second. To fix this, you can set it to use the folder name as part of the file output. These instructions were current as of Visual Studio 2013 (Update 3)

  1. Right click your VC++ project, click “Properties”
  2. Expand “Configuration Properties”
  3. Expand “C/C++”
  4. Select “Output Files”
  5. Select “Object File Name” and change it from “$(IntDir)” to “$(IntDir)/%(RelativeDir)/”

That way, the folder path is taken into account and not just the file name.

All the best for your coding!