警告 MSB8012:确保 $(OutDir)、$(TargetName) 和 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配 [英] warning MSB8012 : make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile)

查看:20
本文介绍了警告 MSB8012:确保 $(OutDir)、$(TargetName) 和 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在构建代码时遇到以下错误.

I am getting the following error when building my code.

C:\程序文件(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5):警告 MSB8012:TargetPath(E:\Study\FWIF\demola\ext-libs\libcommoncpp2-1.6.0\w32\Debug\ccgnu2.dll)与链接器的 OutputFile 属性值不匹配g\CapeCommon14.dll).这可能会导致您的项目构建不正确.要更正此问题,请确保 $(OutDir)、$(TargetName) 和$(TargetExt) 属性值与中指定的值匹配%(Link.OutputFile).

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(E:\Study\FWIF\demola\ext-libs\libcommoncpp2-1.6.0\w32\Debug\ccgnu2.dll) does not match the Linker's OutputFile property value g\CapeCommon14.dll). 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 %(Link.OutputFile).

我希望有人知道该怎么做.

I hope that some one will know what to do.

推荐答案

您是否将项目从以前的版本升级到 Visual Studio 2010?如果是这样,这是一个众所周知的问题.

Did you upgrade a project to Visual Studio 2010 from a previous version? If so, this is a well-known issue.

Visual Studio 2010 C++ 项目升级指南http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx

Visual Studio 2010 C++ Project Upgrade Guide http://blogs.msdn.com/b/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx

升级过程中的警告

以下是您在转换过程中可能遇到的一些常见警告:

Here are some of the common warnings that you may run into during conversion:

1) 链接器输出目录

升级应用程序时您可能会看到的警告之一是 MSB8012:$(TargetPath) 和链接器的 OutputFile 属性值不匹配:

One of the warnings you may see when upgrading you applications is MSB8012: $(TargetPath) and Linker’s OutputFile property value does not match:

  • MSB8012:$(TargetExt) ('.dll') 与项目配置 'Debug| 中的链接器的 OutputFile 属性值 'C:\foo\Debug\MFCActiveX.ocx' ('.ocx') 不匹配Win32'.这可能会导致您的项目构建不正确.要更正此问题,请确保 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配.

  • MSB8012: $(TargetExt) ('.dll') does not match the Linker's OutputFile property value 'C:\foo\Debug\MFCActiveX.ocx' ('.ocx') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetExt) property value matches the value specified in %(Link.OutputFile).

MSB8012:$(TargetPath) ('C:\foo\Debug\MFCActiveX.dll') 与链接器的 OutputFile 属性值 'C:\foo\Debug\MFCActiveX.ocx' ('C:\foo\Debug\MFCActiveX.ocx') 在项目配置 'Debug|Win32' 中.这可能会导致您的项目构建不正确.要更正此问题,请确保 $(TargetPath) 属性值与 %(Link.OutputFile) 中指定的值匹配.

Link.OutputFile 是在属性页上的 Linker -> General -> Output File 中定义的值.默认情况下,其值为 $(OutDir)$(TargetName)$(TargetExt),与 $(TargetPath) 的值相同.然而,当我们从以前的版本转换应用程序时,没有一种简单的方法来解析 Link.OutputFile 以确定 $(TargetName) 和 $(TargetExt) 的值到底是什么,因为不同的客户可能已经格式化他们以不同的方式.为了解决这个问题,我们决定在转换过程中保留 Linker.OutputFile 的值.转换后,$(TargetName) 将默认为 $(ProjectName).$(TargetExt) 将默认为应用程序类型的默认扩展名:动态库为 .dll,静态库为 .lib,应用程序为 .exe.Link.OutputFile 值将被保留.如果 Link.OutputFile 和 $(TargetPath) 不同,则转换日志中将发出警告 MSB8012.构建应用程序时,您将收到相同的警告.

$(OutDir)、$(TargetName) 和 $(TargetExt) 在General"属性页上分别公开为Output Directory"、Target Name"、Target Extension".您可以手动更改这些属性的值,以便不再收到警告.

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).

Link.OutputFile is the value defined at Linker -> General -> Output File on the property page. By default, its value is $(OutDir)$(TargetName)$(TargetExt), which is the same as the value of $(TargetPath). When we convert an application from a previous version, however, there is not an easy way for conversion to parse Link.OutputFile to figure out what exactly the values are for $(TargetName) and $(TargetExt), as different customers may have formatted them in different ways. To work around that, we decided to preserve the value of Linker.OutputFile during conversion. After conversion, $(TargetName) will default to $(ProjectName). $(TargetExt) will default to the default extension for the application type: .dll for Dynamic Library, .lib for Static Library and .exe for Application. Link.OutputFile value will be preserved. Warning MSB8012 will be issued in the conversion log if Link.OutputFile and $(TargetPath) are not the same. You will get the same warnings when building the application.

$(OutDir), $(TargetName) and $(TargetExt) are exposed on the "General" property page, as "Output Directory", "Target Name", "Target Extension", respectively. 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 在转换后设置为默认的 $(TargetPath).您可能需要进行更改,以便在 F5(调试)或 Ctrl + F5(不调试时启动)时启动正确的可执行文件.

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).

这篇关于警告 MSB8012:确保 $(OutDir)、$(TargetName) 和 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆