6

我最近遇到了与 atls.lib 的链接问题。我更新了链接器的附加依赖项:

comctl32.lib
C:\WinDDK\7600.16385.1\lib\ATL\i386\atls.lib
C:\WinDDK\7600.16385.1\lib\ATL\i386\atl.lib
C:\WinDDK\7600.16385.1\lib\ATL\i386\atlsd.lib

但是,现在,我开始收到这些错误。

什么会导致这些问题?

非常感谢你。

------ Build started: Project: hede, Configuration: Debug Win32 ------
Linking...
atlsd.lib(externs.obj) : error LNK2005: "char const * const g_pszUpdateEventName" (?g_pszUpdateEventName@@3PBDB) already defined in atls.lib(externs.obj)
atlsd.lib(externs.obj) : error LNK2005: "char const * const g_pszAllocFileMapName" (?g_pszAllocFileMapName@@3PBDB) already defined in atls.lib(externs.obj)
atlsd.lib(externs.obj) : error LNK2005: "char const * const g_pszKernelObjFmt" (?g_pszKernelObjFmt@@3PBDB) already defined in atls.lib(externs.obj)
atlsd.lib(externs.obj) : error LNK2005: "class CAtlAllocator g_Allocator" (?g_Allocator@@3VCAtlAllocator@@A) already defined in atls.lib(externs.obj)
SettingPropPage.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
stdafx.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
trace.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
util.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
genericpropclasses.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
hede.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
hede2.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
propclasses.obj : error LNK2001: unresolved external symbol __forceAtlDllManifest
propclasses.obj : error LNK2019: unresolved external symbol __imp__AtlWinModuleAddCreateWndData@12 referenced in function "public: void __thiscall ATL::CAtlWinModule::AddCreateWndData(struct ATL::_AtlCreateWndData *,void *)" (?AddCreateWndData@CAtlWinModule@ATL@@QAEXPAU_AtlCreateWndData@2@PAX@Z)
propclasses.obj : error LNK2019: unresolved external symbol "void __stdcall ATL::__FreeStdCallThunk(void *)" (?__FreeStdCallThunk@ATL@@YGXPAX@Z) referenced in function "public: static void __cdecl ATL::_stdcallthunk::operator delete(void *)" (??3_stdcallthunk@ATL@@SAXPAX@Z)
propclasses.obj : error LNK2019: unresolved external symbol __imp__AtlWinModuleExtractCreateWndData@4 referenced in function "public: void * __thiscall ATL::CAtlWinModule::ExtractCreateWndData(void)" (?ExtractCreateWndData@CAtlWinModule@ATL@@QAEPAXXZ)
propclasses.obj : error LNK2019: unresolved external symbol "void * __stdcall ATL::__AllocStdCallThunk(void)" (?__AllocStdCallThunk@ATL@@YGPAXXZ) referenced in function "public: static void * __cdecl ATL::_stdcallthunk::operator new(unsigned int)" (??2_stdcallthunk@ATL@@SAPAXI@Z)
stdafx.obj : error LNK2019: unresolved external symbol __imp__AtlUpdateRegistryFromResourceD@20 referenced in function "public: long __stdcall ATL::CAtlModule::UpdateRegistryFromResourceDHelper(wchar_t const *,int,struct ATL::_ATL_REGMAP_ENTRY *)" (?UpdateRegistryFromResourceDHelper@CAtlModule@ATL@@QAGJPB_WHPAU_ATL_REGMAP_ENTRY@2@@Z)
stdafx.obj : error LNK2019: unresolved external symbol __imp__AtlCreateRegistrar@4 referenced in function "public: long __stdcall ATL::CAtlModule::UpdateRegistryFromResourceDHelper(wchar_t const *,int,struct ATL::_ATL_REGMAP_ENTRY *)" (?UpdateRegistryFromResourceDHelper@CAtlModule@ATL@@QAGJPB_WHPAU_ATL_REGMAP_ENTRY@2@@Z)
stdafx.obj : error LNK2019: unresolved external symbol __imp__AtlCallTermFunc@4 referenced in function "public: void __thiscall ATL::CAtlModule::Term(void)" (?Term@CAtlModule@ATL@@QAEXXZ)
Debug/hede.exe : fatal error LNK1120: 8 unresolved externals
Build log was saved at "file://c:\Users\JohnDoe\Desktop\myproject\hede\Debug\BuildLog.htm"
hede- 20 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
4

3 回答 3

4

在项目设置中,将“使用 ATL”从“动态链接到 ATL”更改为“静态链接到 ATL”。

于 2012-07-27T12:26:26.190 回答
4

我也必须调试这个问题。似乎 DLL bulid 不起作用,因为 atl.lib 中缺少许多函数。我将“使用 ATL”切换为“到 ATL 的静态链接”。之后我只剩下 3 个缺失的符号,我发现这些是在atlthunk.lib. atlbase.h 中从未引用过这个。这就是我添加的原因

#pragma comment(lib, "atlthunk.lib")

atlbase.h调试是/否部分之前atls.lib/atlsd.lib

之后构建成功。

于 2015-08-21T15:50:15.370 回答
2

atls.lib 是 ATL 的静态库。atlsd.lib 是该库的调试版本。您在同一个版本上链接到两者,因此您获得了多个定义。此外,如果您想使用 ATL 的动态库,您应该链接到 atl.lib。因此,要么使用 atl.lib,要么在发布版本中使用 atls.lib,在调试版本中使用 atlsd.lib。但不要将它们混合在一起。

于 2012-06-20T19:08:32.100 回答