c++ - 集成库导致错误 C++

标签 c++ windows directx static-libraries

我在一个包含 DirectX SDK(2010 年 6 月)的 VC++ 2010 Windows 项目中工作,另一个团队生成了一个物理库以合并到程序中。当我通过并执行所有必需的库调用时,以及所有。我按照他们给出的集成库的指示进行操作:

extract the director containing the .h files into my c:\

在 C/C++>general>Additional Include Directories 地方

c:\physics_core        // without additional additional dependencies 

然后在Linker>Input>Additional Dependencies的地方

C:\physics_core\PhysicsCore\Release\PhysicsCore.lib    // without additional additional dependencies 

然后包括管理器,并在需要调用方法和对象的任何地方使用提供的命名空间(智能甚至尝试建议自动完成正确)。但随后我的编译器抛出以下列表。我很确定前 6 个与库本身有关,其他与 directX 有关。

1>  PhysicsCore.lib(PhysicsMgr.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
1>PhysicsCore.lib(PhysicsMgr.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Box3D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Circle3D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Box2D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Circle2D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__UpdateWindow@4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExW@48
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__RegisterClassExW@4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__LoadCursorW@8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcW@16
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage@4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__InvalidateRect@12
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__AddFontResourceExW@12
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__GetWindowRect@8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageW@4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage@4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__PeekMessageW@20
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__UnregisterClassW@8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__RemoveFontResourceExW@12
1>C:\general\...\Engine\Debug\test.exe : fatal error LNK1120: 15 unresolved externals

问题是,当我将程序回滚到集成物理库之前,一切都按预期进行。创建该库的人告诉我它在他们尝试使用它的所有系统上都能正常工作,但他们从未尝试在 Windows 程序中使用它,他们向我保证这与它无关作为一个Windows应用程序。当我问他们是否使用任何特殊标志,如第一个链接器警告状态时,他们说他们没有使用这样的标志(首席程序员甚至不知道它们是什么,也不知道如何设置它们)。集成物理之前的构建让 directX 工作正常甚至渲染。

任何帮助都会很棒。

更新:将 Linker>input>Additional Dependencies 更改为

C:\physics_core\PhysicsCore\Debug\PhysicsCore.lib 可能需要将此更改为原始版本

修复了前 6 个错误,但 Unresolved external 问题仍然存在

更新: 情况解决了。

通过对同一属性行采取 2 个操作来解决所有错误。

1 确保在 Debug模式下使用库的调试版本。

2 检查有问题的库的依赖关系,如果有任何重叠,则包括它们。因为编译器首先检查正在使用的任何库的依赖项列表,然后检查项目的依赖项。如果有任何重叠,第一个会出现,之后的所有重叠都将被忽略,但如果 include dependencies 标志未设置为 true,编译器将不会包含它们。 所以解决这种情况的更正行是在 Linker>Input>Additional Dependencies needed to be changed to:

C:\physics_core\PhysicsCore\Debug\PhysicsCore.lib    // include additional dependencies

再次感谢您的帮助。

最佳答案

必须修改其中一个属性行才能清除所有错误。 第一个变化是必须修正 .lib 的目录以匹配构建 Debug with Debug,并 release with release 的目录。

当重新激活库链接器中的“继承父项或项目默认值”复选框时,其他问题得到解决。 (尽管合并图书馆的方向另有说明。

关于c++ - 集成库导致错误 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9267445/

相关文章:

windows - 是什么使进程在 Windows 中显示为“无响应”?

c++ - IDC 是什么意思?

c++ - CreateDepthStencilView() 失败

c++ - C++ 程序输出与预期不同的原因是什么?

c++ - 为什么我不能在 C++11 中创建一个 lambda vector (相同类型)?

c++ - 使用 boost::lambda 调用成员函数

graphics - DirectDraw 叠加

c++ - pthread_cond_wait 有时会收不到信号

windows - 如何正确定位 DBGrid 中的图标?

c++ - 顶点颜色无法正常工作