Visual Studio 2010库链接错误

Visual Studio 2010库链接错误

问题描述:

当我尝试在项目中使用DCMTK(/MT)库时,出现以下链接错误.我确定这些错误与VS2010的ws2_32.lib wsock32.lib netapi32.lib有关.但是我已经将这三个库添加到了项目属性中.您可以看到库已被搜索,如下所示.这些库位于C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v7.0A \ lib中.订单问题?有什么建议吗?

I got the following linking errors when I tried to use DCMTK (/MT) library in my project. I am sure that the errors are related to ws2_32.lib wsock32.lib netapi32.lib of VS2010. But I have already added these three libs to the project property. You can see the libs had been searched as shown below. The libs are in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib. order problem? Any suggestion?

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__CopySid@12 referenced in function "bool __cdecl `anonymous namespace'::CopySid(struct _SID * *,struct _SID *)" (?CopySid@?A0x4f6604f8@@YA_NPAPAU_SID@@PAU2@@Z)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__GetLengthSid@4 referenced in function "bool __cdecl `anonymous namespace'::CopySid(struct _SID * *,struct _SID *)" (?CopySid@?A0x4f6604f8@@YA_NPAPAU_SID@@PAU2@@Z)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__GetTokenInformation@20 referenced in function "bool __cdecl `anonymous namespace'::GetCurrentUserSID(struct _SID * *)" (?GetCurrentUserSID@?A0x4f6604f8@@YA_NPAPAU_SID@@@Z)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__OpenProcessToken@12 referenced in function "bool __cdecl `anonymous namespace'::GetCurrentUserSID(struct _SID * *)" (?GetCurrentUserSID@?A0x4f6604f8@@YA_NPAPAU_SID@@@Z)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__RegCreateKeyExA@36 referenced in function "struct HKEY __ * __cdecl `anonymous namespace'::regGetKey(class OFString const &,unsigned long *)" (?regGetKey@?A0x4f6604f8@@YAPAUHKEY __@@ABVOFString@@PAK@Z)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__RegSetValueExA@24 referenced in function "void __cdecl `anonymous namespace'::regSetString(struct HKEY __ *,class OFString const &,class OFString const &)" (?regSetString@?A0x4f6604f8@@YAXPAUHKEY __@@ABVOFString@@1@Z)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__RegisterEventSourceA@8 referenced in function "protected: void __thiscall log4cplus::NTEventLogAppender::init(void)" (?init@NTEventLogAppender@log4cplus@@IAEXXZ)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__DeregisterEventSource@4 referenced in function "public: virtual void __thiscall log4cplus::NTEventLogAppender::close(void)" (?close@NTEventLogAppender@log4cplus@@UAEXXZ)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__ReportEventA@36 referenced in function "protected: virtual void __thiscall log4cplus::NTEventLogAppender::append(class log4cplus::spi::InternalLoggingEvent const &)" (?append@NTEventLogAppender@log4cplus@@MAEXABVInternalLoggingEvent@spi@2@@Z)

1>oflog.lib(ntelogap.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "protected: void __thiscall log4cplus::NTEventLogAppender::addRegistryInfo(void)" (?addRegistryInfo@NTEventLogAppender@log4cplus@@IAEXXZ)

这是lib搜索的详细内容:

Here is the part of the verbose of lib searching:

1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\ws2_32.lib:
1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\netapi32.lib:
1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\wsock32.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\libcpmtd.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\LIBCMT.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:

....

1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\msvcprtd.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\MSVCRTD.lib:
1>      Searching C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\LIBCMTD.lib:
1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1>      Searching C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
....

好像没有链接到 Advapi32.lib .将其添加到项目属性中的链接器->输入->其他依赖项.不要忘记为所有项目配置添加它(分别从配置"和平台"下拉列表中选择所有配置"和所有平台").

Looks like you aren't linking in Advapi32.lib. Add that to Linker -> Input -> Additional Dependencies in your project properties. Don't forget to add it for all of your project configurations (select "All Configurations" and "All Platforms" from the Configuration and Platform dropdowns, respectively).