Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix warning MSB8012 in a static library project in Visual C++ 2010?

I am trying to convert a static library from VC++2008 to VC++2010, and I get these warnings about TargetPath and TargetName. I have had a look into my configuration and I'm not sure how to make these go away. Is it serious or is it really just an ignorable warning, for a static library that I usually build once and rarely rebuild.

I think it has something to do with the fact that the project is named itk32, but the debug version of the library is named itk32d.lib, and the old way that this is configured in Visual C++ 6.0 era has resulted in some kind of weird settings staying in the vc2010 project, which was converted a while ago from VC6 to 2008, and I am now converting to 2010:

1>------ Build started: Project: Itk32, Configuration: Debug Win32 ------
1>...\Microsoft.CppBuild.targets(1151,5): warning MSB8012: TargetPath(C:\...\Libraries\Itk\.\Debug\Itk32d.lib.lib) does not match the Library's OutputFile property value (C:\...\Libraries\Itk\Debug\Itk32d.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>...\Microsoft.CppBuild.targets(1153,5): warning MSB8012: TargetName(Itk32d.lib) does not match the Library's OutputFile property value (Itk32d). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
like image 214
Warren P Avatar asked Jun 01 '13 19:06

Warren P


2 Answers

The build system was dramatically overhauled in VS2010, it now uses MSBuild instead of the custom VCBuild system. The same build system used by other languages supported by VS. They did a pretty good job of making that invisible, old projects normally build just fine. But there are a few places where you can get in trouble when you import old projects. Which is what this warning is saying.

Using the linker's General + Output File setting to name the output file is one such troublespot. Not actually that sure what can go wrong, it probably has something to do with dependency checking. The default setting for it is $(OutDir)$(TargetName)$(TargetExt). The best way to rename the output file is therefore to change the $(TargetName) macro value.

Which is available on the main General page as the "Target Name" setting. It didn't exist in earlier VS versions. So change that one to "itk32d". Or better, $(ProjectName)d. And reset the linker setting.

like image 141
Hans Passant Avatar answered Oct 21 '22 21:10

Hans Passant


I had this problem but could not find a valid answer here in SO, eventually I found out that it was solved by fixing the Intermediate Directory from ".\Debug" to "..\Debug", and ".\Release" to "..\Release" in each build configuration.

I'm sorry this is only worth for a comment but I don't have enough points to add comments to other people's posts.

like image 43
blit Avatar answered Oct 21 '22 19:10

blit