我有一个第三方库,我有错误LNK2019:未解析的外部..如何调查以修复它

I have a third party lib, I have error LNK2019: unresolved external ... How to investigate to fix it

本文关键字:调查 何调查 外部 第三方 有一个 有错误 LNK2019      更新时间:2023-10-16

我有一个第三方libs。(msvc10)MT/MD(静态cfgs)和动态DLL cfg
我有qt+msvc10快递+win sdk.7

好的,我使用现有的例子,(使用libs)我不能编译。。。。。我有4个未解决的相同库的外部错误。(但我对其他人没有任何错误)我不支持这些自由。。。。。。(但它们是合法的,我是没有权利的会员)

调查可能的解决方案的步骤是什么?我要去哪里看?谢谢

编辑1:

错误是:

TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegEnumValueW@32 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor@ExHostAppServices@@UAE_N ABVOdTtfDescriptor@@AAVOdString@@@Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor@ExHostAppServices@@UAE_N ABVOdTtfDescriptor@@AAVOdString@@@Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExW@24 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor@ExHostAppServices@@UAE_N ABVOdTtfDescriptor@@AAVOdString@@@Z)
TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExW@20 referenced in function "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(class OdTtfDescriptor const &,class OdString &)" (?ttfFileNameByDescriptor@ExHostAppServices@@UAE_N ABVOdTtfDescriptor@@AAVOdString@@@Z)
..exeOdaQtApp.exe : fatal error LNK1120: 13 unresolved externals

在这篇文章中,我收到了一个解决方案:我必须链接到Advapi32.lib。。。我的问题是:我怎么能知道这一点
我试过dependencyywalker,但它不能使用.lib…

在这篇文章中,我收到了一个解决方案:我必须与Advapi32.lib链接……我的问题是:我怎么能知道这一点?

当你从链接器中得到一个"未解析的外部"错误时,这意味着它正在寻找某个对象文件所需的函数或变量名的匹配项,而链接器找不到在其中一个对象文件或库中定义的名称。

从这些错误中的第一个开始(我对它进行了重新格式化,使其可读性略高——我鼓励你下次遇到其中一个错误时也这样做):

TD_ExamplesCommon.lib(ExHostAppServices.obj) : error LNK2019: unresolved external symbol
      __imp__RegEnumValueW@32 referenced in function 
      "public: virtual bool __thiscall ExHostAppServices::ttfFileNameByDescriptor(
            class OdTtfDescriptor const &,class OdString &)"
      (?ttfFileNameByDescriptor@ExHostAppServices@@UAE_N ABVOdTtfDescriptor@@AAVOdString@@@Z)

错误消息中有很多内容(其中大部分看起来像垃圾)。幸运的是,在大多数情况下,大部分都可以忽略。最重要的一点是链接器正在寻找符号__imp__RegEnumValueW@32。这个名称上有一些黏糊糊的东西,但幸运的是,它无论如何都很容易识别。

  • CCD_ 2前缀指示它正在寻找DLL导入。在几乎所有情况下,出于您的目的,这些都可以忽略
  • @32后缀是Microsoft编译器为某些调用约定添加到函数名中的东西。对于您的目的来说,它通常也不重要(对于记录,它表明函数需要32字节的参数数据)

因此,我们只剩下链接器正在查找RegEnumValueW这一事实。这看起来很像Win32 API的名称。

如果您查看RegEnumValueW(或RegEnumValue,因为许多Win32 API都有AW变体来处理ANSI/UNICODE构建)的文档,我们会在文档中发现以下信息:

    Requirements
    Minimum supported client        Windows 2000 Professional
    Minimum supported server        Windows 2000 Server
    Header                          Winreg.h (include Windows.h)
 >> Library                         Advapi32.lib
    DLL                             Advapi32.dll
    Unicode and ANSI names          RegEnumValueW (Unicode) and 
                                    RegEnumValueA (ANSI)

这就是为什么你知道你需要advapi32.lib

因此,将来,当您从链接器中收到"未解决的外部"错误时,只需忽略错误消息中的大部分内容,并将注意力集中在它所说的找不到的符号上——这将导致您找到可能丢失的库、对象文件或其他项。

作为记录,advapi32.lib将被大多数复杂的Windows应用程序所需要。

您可以尝试使用dependencywalker来查看dll的依赖项列表,并查看它缺少什么。

您是否在链接器选项中输入了*.lib文件?(input-->附加依赖项"),以及库目录中.lib选项的路径?