如何修复 Visual C++ 2010 静态库项目中的警告 MSB8012? [英] How do I fix warning MSB8012 in a static library project in Visual C++ 2010?

查看:29
本文介绍了如何修复 Visual C++ 2010 静态库项目中的警告 MSB8012?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将静态库从 VC++2008 转换为 VC++2010,我得到这些关于 TargetPath 和 TargetName 的警告.我查看了我的配置我不知道如何让这些消失.对于我通常构建一次很少重建的静态库,它是严重的还是真的只是一个可忽略的警告.

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.

我觉得跟项目叫itk32有关系,但是这个库的debug版本叫itk32d.lib,Visual C++ 6.0时代老的配置方式导致了一些留在 vc2010 中的奇怪设置项目,前段时间从VC6转换到2008,我现在转换到2010:

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 ==========

推荐答案

构建系统在 VS2010 中进行了大幅改进,现在使用 MSBuild 而不是自定义 VCBuild 系统.VS 支持的其他语言使用的相同构建系统.他们做得很好,使那些不可见的旧项目通常构建得很好.但是在导入旧项目时,有些地方可能会遇到麻烦.这就是这个警告所说的.

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.

使用链接器的常规 + 输出文件设置来命名输出文件就是这样的一个问题.实际上并不确定会出现什么问题,它可能与依赖项检查有关.它的默认设置是 $(OutDir)$(TargetName)$(TargetExt).因此,重命名输出文件的最佳方法是更改​​ $(TargetName) 宏值.

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.

可在主常规页面上作为目标名称"设置使用.它在早期的 VS 版本中不存在.所以把那个改成itk32d".或者更好,$(ProjectName)d.并重置链接器设置.

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.

这篇关于如何修复 Visual C++ 2010 静态库项目中的警告 MSB8012?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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