Warning MSB8012: TargetPath and 'Linker's OutputFile' not evaluated the same way
-
Monday, August 08, 2011 9:48 PM
Hello,
Recently, I converted my VS2005 project to VS2010 and ran into the MSB8012 warning issue. I have reviewed the literature available regarding this issue, but it does not seem to apply to my case. I asked this question before in 'Visual Studio Setup and Installation', but was directed here.
Here are the details:
Config Properties -> General->:
Output Directory: .\..\..\..\..\..\BinDir
TargetName: $(ProjectName)
Target Ext: .dll
linker -> General->:
OutPut File: .\..\..\..\..\..\BinDir\libMyProj.dll
The warning I get is =>
warning MSB8012: TargetPath(C:\Main\Product\d1\d2\d3\d4\libMyProj\.\..\..\..\..\..\..\BinDir\libMyProj.dll) does not match the Linker's OutputFile property value (C:\Main\Product\BinDir\libMyProj.dll). ........
Note that: On my machine 'C:\Main\Product\d1\d2\d3\d4\libMyProj\.\..\..\..\..\..\..\BinDir\libMyProj.dll' is same as C:\Main\Product\BinDir\libMyProj.dll
Even though the TargetPath evaluates to the same final file => C:\Main\Product\BinDir\libMyProj.dll, I get the warning. I understand that this happens as the two strings are different. But the thing I don't understand is that why 'Linker's OutputFile' does not show up exactly as setup under the property pages. It should show up as 'C:\Main\Product\d1\d2\d3\d4\libMyProj\.\..\..\..\..\..\..\BinDir\libMyProj.dll'. If it maintains its form then it would match with the TargetPath perfectly. Instead the Linker's output file gets the evaluated to 'C:\Main\Product\BinDir\libMyProj.dll', hence the mismatch.
I would appreciate your input/help with this issue.
Regards,
Chai.
All Replies
-
Wednesday, August 10, 2011 6:46 AMModerator
Hi ChaiTchai,
One of the warnings you may see when upgrading you applications to VS2010 is MSB8012: $(TargetPath) and Linker’s OutputFile property value does not match:
- MSB8012: $(TargetPath) ('C:\foo\Debug\MFCActiveX.dll') does not match the Linker's OutputFile property value 'C:\foo\Debug\MFCActiveX.ocx' ('C:\foo\Debug\MFCActiveX.ocx') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetPath) property value matches the value specified in %(Link.OutputFile).
You can manually change the values of these properties so that you no longer get the warning.
-If your project produces Import Library (Linker -> Advanced -> Import Library), you may need to change the Output folder of the Import Library as well after conversion if the Linker output directory is not the default output directory. Otherwise, the generated import lib maybe in a different directory than the linker output.
-Debugging.Command is set to default $(TargetPath) after conversion. You may need to make changes so that the right executable will be launched upon F5 (Debugging) or Ctrl + F5 (Start without debugging).
More detailed information:
http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx
Related thread:
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/beb1c32f-3893-4061-81a7-4aed4032a367
Please mark the useful reply as answer.
Best regards,
Lucy
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marked As Answer by lucy-liuModerator Tuesday, August 16, 2011 8:40 AM
- Unmarked As Answer by ChaiTchai Wednesday, August 24, 2011 4:11 PM
-
Wednesday, August 24, 2011 4:19 PM
I am sorry but I had to mark your reply as 'non-answer'. Note that the warning is
warning MSB8012: TargetPath(C:\Main\Product\d1\d2\d3\d4\libMyProj\.\..\..\..\..\..\..\BinDir\libMyProj.dll) does not match the Linker's OutputFile property value (C:\Main\Product\BinDir\libMyProj.dll). ........
But Linker's OutputFile property value as stated in the warning is INCORRECT. And that is my issue. It should be as it shows up under
'linker -> General->:' OutPut File: .\..\..\..\..\..\BinDir\libMyProj.dll
If it is like that, then it would match with the TargetPath and hence there be no error.
-
Thursday, February 09, 2012 4:06 PM
Hey there.
Solution is quite easy to fix :
Imagine you have :
Linker->Output File = ../../bin/todo.exe
=> simply set into :
General -> Output Directory : ../../bin/ (do not forget the \ at the end)
General -> Target Name : todo
General-> Target Extension : .exe
It's as easy
hope this helps !!
-
Monday, February 13, 2012 10:55 PM
Hello KilroyFR,<o:p></o:p>
Thank you for your reply, but it does not solve my issue. I already have the Output Directory path as you have suggested. But VS2010 evaluates the path rather than simply concatenating the Output Directory and TargetName. So even when Output Directory is setup to ‘../../bin/’ it gets evaluated to the absolute path.<o:p></o:p>
-
Tuesday, May 01, 2012 4:07 PMI had the same trouble using relative paths in the Output dir, but getting a complaint that it did not match the linker's output file. turns out i was able to fix it by using $(OutDir)$(TargetName)$(TargetExt) in the linker output instead of typing the the filename directly.

