简体   繁体   English

MSVC - C ++ - 发布版本失败 - 链接器错误

[英]MSVC - C++ - Release build failed - linker error

HI, HI,

If I am trying to build and link my app in Release mode, i got linker error: 如果我尝试在发布模式下构建和链接我的应用程序,我收到链接器错误:

Error 72 error LNK2001: unresolved external symbol "public: __thiscall MyModels::MT6::MT6(double)" (??0MT6@MyModels@@QAE@N@Z) C:\\Martin\\Programing\\WoknaTest\\WoknaTest\\DXForm.obj WoknaTest 错误72错误LNK2001:未解析的外部符号“public:__thiscall MyModels :: MT6 :: MT6(double)”(?? 0MT6 @ MyModels @@ QAE @ N @ Z)C:\\ Martin \\ Programing \\ WoknaTest \\ WoknaTest \\ DXForm。 obj WoknaTest

In debug mode everything works fine.... what could be possibly wrong ? 在调试模式下一切正常....可能出错的是什么?

Thanks 谢谢

Judging from the fact that it builds successfully in the debug configuration, my first suggestion would be to check the additional dependencies supplied to the linker. 从它在调试配置中成功构建的事实来看,我的第一个建议是检查提供给链接器的其他依赖项。 This setting would be Additional Dependencies setting under Project -> Properties -> Configuration Properties -> Linker -> Input . 此设置将是“ Project -> Properties -> Configuration Properties -> Linker -> Input下的Project -> Properties -> Configuration Properties -> Linker -> Input Additional Dependencies设置。 Make sure this setting matches what is under the debug configuration, assuming there aren't debug-build-specific library names. 假设没有特定于调试版本的库名称,请确保此设置与调试配置下的设置相匹配。

I'd check in the Project settings that all the .lib includes and dlls are included in both Release and Debug modes. 我在项目设置中检查所有.lib包含和dll都包含在Release和Debug模式中。

The solution to this is probably in the project settings for linking somewhere (either .lib .dll or path includes) , but I can't really tell you exactly where from the info. 对此的解决方案可能是在某个地方链接的项目设置(.lib .dll或路径包含),但我无法确切地告诉您信息的确切位置。 you provided. 你提供。

Most likely version (provided that you didn't manually edit your project settings) is that there is some library referenced by your code and you don't have the release version of your library. 最有可能的版本(假设您没有手动编辑项目设置)是您的代码引用了一些库,而您没有库的发行版本。 Typically, the linker references libraries with "d" suffix for debug and without it for release. 通常,链接器引用带有“d”后缀的库以进行调试,而不使用它进行发布。

For example: you have a project VectorMath in your solution. 例如:您的解决方案中有一个项目VectorMath。 The project by default builds a library vectormathd.lib in debug config and vectormath.lib in release. 默认情况下,该项目在debug config和vectormath.lib中构建库vectormathd.lib。 If your dependencies are screwed up and you have never build a release version of vectormath, you'll build your main project in release and it will be looking for vectormath.lib, which you won't have - hence the unresolved external symbol. 如果您的依赖项被搞砸了,并且您从未构建了vectormath的发布版本,那么您将在发布版本中构建您的主项目,它将寻找您不会拥有的vectormath.lib - 因此未解析的外部符号。 The solution would be to make sure that all projects are built in release mode, or fix the dependencies to have the VS do that for you. 解决方案是确保所有项目都以发布模式构建,或者修复依赖项以让VS为您执行此操作。

For me, it is always a this 2 solutions: 对我来说,它始终是这两个解决方案:

  1. Project Properties > Configuration Properties > Linker > General, Link Library Dependencies = Yes 项目属性>配置属性>链接器>常规,链接库依赖关系=是
  2. Project Properties > Configuration Properties > Linker > Input, Additional Dependencies, Edit. 项目属性>配置属性>链接器>输入,附加依赖项,编辑。 Check 'Inherit from parent or project defaults' 选中'从父项或项目默认值继承'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM