C++ 链接器输出文件属性文件与目标路径不匹配?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4700081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linker outfile property file does not match targetpath?
提问by Rishi
I'm trying to compile a .DLL for an application called sierra chart.
我正在尝试为名为 sierra chart 的应用程序编译一个 .DLL。
Here is the warning I get that I need to fix so it all points to the linker output value:
这是我收到的需要修复的警告,因此它都指向链接器输出值:
warning MSB8012: TargetPath(C:\SierraChart\VCProject\Release\SCStudies.dll) does not match the Linker's OutputFile property value (c:\sierrachart\data\SCStudies.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). C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets
警告 MSB8012:TargetPath(C:\SierraChart\VCProject\Release\SCStudies.dll) 与链接器的 OutputFile 属性值 (c:\sierrachart\data\SCStudies.dll) 不匹配。这可能会导致您的项目构建不正确。要更正此问题,请确保 $(OutDir)、$(TargetName) 和 $(TargetExt) 属性值与 %(Link.OutputFile) 中指定的值匹配。C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets
Any ideas?
有任何想法吗?
回答by Mashmagar
I believe this warning appears specifically when upgrading a C++ project to VS2010. Visual Studio 2010 C++ Project Upgrade Guidedescribes some of the caveats encountered during an upgrade. If you're uncomfortable changing project settings, then retaining the older version of Visual Studio, may work for you.
我相信在将 C++ 项目升级到 VS2010 时会特别出现此警告。Visual Studio 2010 C++ 项目升级指南描述了升级过程中遇到的一些注意事项。如果您对更改项目设置感到不舒服,那么保留旧版本的 Visual Studio 可能对您有用。
To change the %(Link.OutputFile)
, open the project properties. Navigate to Configuration Properties -> Linker -> General. You can set the Output File to $(OutDir)\SCStudies.dll
, which should take care of your issue. You may need to repeat the change for each Configuration/Flavor you will be building (Debug/x86, Release/x86, Debug/Itanium, etc...).
要更改%(Link.OutputFile)
,请打开项目属性。导航到配置属性 -> 链接器 -> 常规。您可以将输出文件设置为$(OutDir)\SCStudies.dll
,这应该可以解决您的问题。您可能需要对将要构建的每个配置/风格(Debug/x86、Release/x86、Debug/Itanium 等)重复更改。
回答by DanielV
回答by ngzaharias
A different fix which others haven't mentioned is that by default the TargetExt is .exe
and for my debug builds I changed it to be _d.exe
, where instead you should be doing that in the TargetName path.
其他人没有提到的另一个修复是默认情况下 TargetExt 是.exe
,对于我的调试版本,我将其更改为_d.exe
,而您应该在 TargetName 路径中执行此操作。
回答by Sergey Shevchenko
The original configuration was set like:
原始配置设置如下:
Properties -> Linker -> General :
$(OutDir)\"<'name fileA>".exe
属性 -> 链接器 -> 常规:
$(OutDir)\"<'name fileA>".exe
The program tries to run "<'name_project>
".exe and as result error Linked.
该程序尝试运行“ <'name_project>
”.exe,结果错误链接。
You need to set the configuration as:
您需要将配置设置为:
Properties -> Linker -> General :
$(OutDir)\"<'project name>".exe
属性 -> 链接器 -> 常规:
$(OutDir)\"<'project name>".exe
回答by Rishi
Looks like it's not significant for the program:
看起来对程序来说并不重要:
Odd Visual Studio error when following the custom study video
回答by Gerardo Hernandez
The directory specified in General->Output Directory and the directory specified in the path at Linker->Output File have to match.
General->Output Directory 中指定的目录和 Linker->Output File 路径中指定的目录必须匹配。
If you want to change the defaults do things in these order: You first configure the OutDir in General->Output Directory. E.g.
如果要更改默认值,请按以下顺序执行操作:首先在 General->Output Directory 中配置 OutDir。例如
$(SolutionDir)$(Platform)$(Configuration)\MyProgram\
Make sure Output File is consistent. E.g. this would work
确保输出文件一致。例如这会起作用
$(OutDir)$(TargetName)$(TargetExt)
回答by Ivan
The comment from Gerardo Hernandez helped me.
Gerardo Hernandez 的评论对我很有帮助。
The directory specified in General->Output Directory and the directory specified in the path at Linker->Output File have to match.
General->Output Directory 中指定的目录和 Linker->Output File 路径中指定的目录必须匹配。
In my case I was importing a large project from Visual Studio 6 and
就我而言,我从 Visual Studio 6 导入了一个大型项目
C:\Project\myproject\OneOfMyDlls\.\Debug\OneOfMyDlls.dll
C:\Project\myproject\OneOfMyDlls\.\Debug\OneOfMyDlls.dll
was not equal to
不等于
C:\Project\myproject\Debug\OneOfMyDlls.dll
C:\Project\myproject\Debug\OneOfMyDlls.dll
but
但
C:\Project\myproject\OneOfMyDlls\..\Debug\OneOfMyDlls.dll
C:\Project\myproject\OneOfMyDlls\..\Debug\OneOfMyDlls.dll
would have been, after path reduction.
本来是,在路径减少之后。
The problem was that the Visual Studio 2017 import had changed the output directory from
..\Debug
to .\Debug
assuming that the unconventional parent directory use was a mistake. In a large project with 13 DLLs of our own, (never mind second and third party DLLs too), it makes sense to collect all the DLLs in one place and ..\Debug
was correct.
问题是 Visual Studio 2017 导入已将输出目录从 更改
..\Debug
为.\Debug
假设非常规父目录的使用是错误的。在一个拥有 13 个我们自己的 DLL(更不用说第二和第三方 DLL)的大型项目中,将所有 DLL 收集在一个地方..\Debug
是有意义的,并且是正确的。
So while others might have had to change Linker->Output File
, in my case it was General->Output Directory
which needed to change as it had been corrupted by the import from Visual Studio 6.
因此,虽然其他人可能不得不更改Linker->Output File
,但在我的情况下,General->Output Directory
它需要更改,因为它已被从 Visual Studio 6 导入损坏。
Something like ..\Debug
had become something like .\Debug
after import. (The real project specific names have been removed .)
类似的..\Debug
东西.\Debug
在导入后变成了类似的东西。(真正的项目特定名称已被删除。)