This question is an addition for Visual Studio 2010's strange “warning LNK4042”. Shortly, Visual Studio makes the following folders structure flat for generated C++ object files -> same name object files are overwritten -> which causes linker errors.
/FolderA/
SameFileName.cpp
SameFileName.h
/FolderB/
SameFileName.cpp
SameFileName.h
The solution is applying
$(IntDir)/%(RelativeDir)/
at VS C++ project option: C/C++ -> Output Files -> "Object File Name"
But this solution is failing for Managed C++ project. At last compilation step compiler generates file for managed project in temporal folder:
"C:\Users\my_name\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp"
which causes an error because of "/%(RelativeDir)/":
Error 35 error C1083: Cannot open compiler generated file: 'C:\Users\my_name\AppData\Local\Temp\/x86\Debug\.NETFramework,Version=v4.0.AssemblyAttributes.obj': No such file or directory C:\Users\my_name\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp 1
This makes me a bit sad since I have to end up with ugly files' names which are unique. Maybe some of you had same problem and solved it more gracefully? Thx!