libgcrypt.lib中的未解析外部符号

3

如果我在.lib(库)文件中发现未解决的外部符号,我该怎么办?如果我在.c或.cpp文件中发现未解决的外部符号,我可以解决它。但是当我在.lib(库)文件中发现未解决的外部符号时,我该如何解决?

在我的情况下,我发现了这样的链接器错误:

Error 1 error LNK2019: unresolved external symbol ___mingw_vfprintf referenced in function _fprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) Error 2 error LNK2001: unresolved external symbol ___mingw_vfprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-misc.o) Error 3 error LNK2001: unresolved external symbol _gpg_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ecc.o) Error 4 error LNK2019: unresolved external symbol _gpg_strerror referenced in function __gcry_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) Error 5 error LNK2001: unresolved external symbol _gpg_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-misc.o) Error 6 error LNK2001: unresolved external symbol _gpg_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(md.o) Error 7 error LNK2001: unresolved external symbol _gpg_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-fips.o) Error 8 error LNK2019: unresolved external symbol _gpg_strsource referenced in function __gcry_strsource D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) Error 9 error LNK2019: unresolved external symbol _gpg_err_set_errno referenced in function _do_malloc D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) Error 10 error LNK2001: unresolved external symbol _gpg_err_set_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-stdmem.o) Error 11 error LNK2001: unresolved external symbol _gpg_err_set_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-secmem.o) Error 12 error LNK2001: unresolved external symbol _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-module.o) Error 13 error LNK2019: unresolved external symbol _gpg_err_code_from_errno referenced in function _gpg_err_make_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) Error 14 error LNK2001: unresolved external symbol _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-sexp.o) Error 15 error LNK2001: unresolved external symbol _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(md.o) Error 16 error LNK2001: unresolved external symbol _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(primegen.o) Error 17 error LNK2019: unresolved external symbol ___mingw_vsprintf referenced in function _sprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-sexp.o) Error 18 error LNK2001: unresolved external symbol ___mingw_vsprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ac.o) Error 19 error LNK2001: unresolved external symbol _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(primegen.o) Error 20 error LNK2019: unresolved external symbol _gpg_err_code_from_syserror referenced in function _progress D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(dsa.o) Error 21 error LNK2001: unresolved external symbol _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ecc.o) Error 22 error LNK2001: unresolved external symbol _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(random-fips.o) Error 23 error LNK2001: unresolved external symbol _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(mpicoder.o) Error 24 error LNK2001: unresolved external symbol _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(cipher.o) Error 25 error LNK2001: unresolved external symbol _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(pubkey.o) Error 26 error LNK2001: unresolved external symbol _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(kdf.o) Error 27 error LNK2019: unresolved external symbol _snprintf referenced in function __gcry_pk_get_keygrip D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(pubkey.o) Error 28 error LNK2001: unresolved external symbol _snprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(md.o) Error 29 error LNK2001: unresolved external symbol _snprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ecc.o) Error 30 error LNK2001: unresolved external symbol _snprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(rndw32.o) Error 31 error LNK2019: unresolved external symbol _getpagesize referenced in function _init_pool D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-secmem.o) Error 32 error LNK2019: unresolved external symbol _gettimeofday referenced in function _x931_get_dt D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(random-fips.o) Error 33 error LNK2001: unresolved external symbol _gettimeofday D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(random-csprng.o) Error 34 error LNK1120: 10 unresolved externals D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\Release\libvlccore.dll Error 89 error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall UpdateDialog::metaObject(void)const " (?metaObject@UpdateDialog@@UBEPBUQMetaObject@@XZ) D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\lib_plugin\help.obj Error 90 error LNK2001: unresolved external symbol "public: virtual void * __thiscall UpdateDialog::qt_metacast(char const *)" (?qt_metacast@UpdateDialog@@UAEPAXPBD@Z) D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\lib_plugin\help.obj Error 91 error LNK2001: unresolved external symbol "public: virtual int __thiscall UpdateDialog::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@UpdateDialog@@UAEHW4Call@QMetaObject@@HPAPAX@Z) D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\lib_plugin\help.obj Error 92 error LNK1120: 3 unresolved externals D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\Release\plugins\lib_plugin.dll

任何有关此事的建议都将非常有帮助。

1
你可能需要导入一个包含缺失符号的附加库。 - Roger Rowland
我也遇到了同样的问题。有解决方案吗? - adarshaU
@RogerRowland 感谢您的回复。但是我该如何知道所需的 .lib 文件呢? - Myanju
2
我猜测相关库(libgcrypt?)应该有文档,可能还有一个config.h文件可以检查以确保您没有选择不合适的选项。也许您应该重新表达问题,并尝试找到使用相同库的用户。 - Roger Rowland
@RogerRowland 我在config.h中添加了#define UPDATE_CHECK。 - Myanju
@Myanju 怎么办?通常谷歌会提供详细信息。那个装饰的名称非常具体,所以我敢打赌它会找到类似于你的问题。 - JDługosz
2个回答

3
好的,基本上你需要找到包含该符号的库文件 - .lib或.a文件(取决于平台)。静态库在链接到可执行文件或共享库时才解析其符号,因此可能有一个静态库未解析所有符号。您可以使用下面提到的工具来验证这一点 - 当您转储符号时,未解析的符号将在它们之前有一个 U 字母。当您将它们链接到应用程序中时,链接器必须解析所有符号,如果缺少某些内容,则会出现未解决的引用错误。您基本上有两个选择:

1)使用符号转储实用程序,如 nm (Linux和Windows上的MinGW)或 dumpbin (Windows上的Visual Studio),并针对符号进行grep (如果您有一个包含许多库的目录,您可以制作一个为每个文件执行此操作的脚本),然后当您知道正确的库文件时,对其进行链接(对于Linux和MinGW Windows取决于平台-l<library name>开关,在Visual Studio中通过#pragma comment(lib, "<library name>")或通过属性页指定库。

2)如果所有库都有源代码,您可以进行简单的文本搜索以查找函数的定义,然后链接到具有源代码的库即可。

3)即使您已经链接到适当的库,这些问题也可能出现,但混合了C和C ++代码。具有C接口的库应该将其头包含在 extern "C" 块中,以便链接器不会尝试在仅提供C名称函数时找到具有C ++名称的函数。对于初学者来说,这是FFmpeg和其他大型开源项目的常见问题。

更新

至于与 __mingw_vfprinf 的原始问题 - 这有点奇怪,因为您正在使用MinGW编译的代码与Visual Studio链接,我想你最好也使用MinGW进行项目,但正如类似主题所建议的,这可能是由于缺少 libmingwex.a 引起的。如果您拥有MinGW工具链,请找到文件所在的位置,通过Visual Studio属性页面将该目录添加到链接器搜索目录中,并通过上面提到的pragma将 libmingwex.a 作为链接器输入添加到您的项目中。如果您没有MinGW工具链,则应下载它,但是您需要获取正确的平台 - 但我猜由于您从某个地方获取了库,您知道它是32位还是64位。

更新2

这是MinGW软件包管理器的示例截图,显示包含库的软件包:

MinGW package manager showing libmingwex.a


谢谢回复。我已经下载并安装了MinGW,但是在安装目录中没有找到libmingwex.a文件。我是否需要在MinGW安装管理器中选择特定的软件包? - Myanju
好的,我查看了我的MinGW安装,我在C:\MinGW\libC:\MinGW\mingw32\lib下有libmingwex.a,它似乎是mingw32-mingwrt包的一部分。请参见答案附带的图片。顺便说一句,我没有看到更新的问题和额外未解决的符号,这可能需要更多的库。 - Rudolfs Bundulis
@Myanju,有没有解决MinGW所依赖的问题的进展? - Rudolfs Bundulis
@Myanju,你本可以更快地发布这些信息。根据他们的维基 https://wiki.videolan.org/Win32Compile/,你应该使用MinGW在Windows上构建VLC,这很可能是为什么你在Visual Studio中遇到所有问题的原因。如果你有时间聊天,我可以尝试帮忙。 - Rudolfs Bundulis
@RudolfsBundulis 谢谢。我已加入。 - Myanju
显示剩余14条评论

1
我的其他运行时库实现经验表明,各种printf变体是通过调用较低级别的vprintf形式来实现的。fprintf被放入那个.o文件中(为什么?难道它本身不是RTL函数吗?)并且它需要那个辅助函数。从名称修饰中可以看出,我希望它可以在mingw系统库中找到。我认为printf函数在一个补充库中,你需要链接它,因为它比msvcrt.dll中的函数更强大。
所以,请查找它。也要检查您的版本,因为可能该库是针对不同于您当前使用的版本构建的,而这些细节已经发生了变化。

谢谢回复。我该如何将msvcrt.dll链接到我的项目中? - Myanju
你已经在这方面有所了解。我认为你应该重新审视mingw的编译/链接架构基础以及它与Windows system32库(msvcrt)的关系。 - JDługosz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接