如果我在 .lib(library) 文件中发现未解析的外部符号,我必须做什么。如果我在 .c 或 .cpp 中发现无法解析的外部符号,我可以修复它。但是当我在 .lib(library) 文件中发现未解析的外部符号时,我该如何解决这个问题?
就我而言,我发现了这样的链接器错误:
错误 1 错误 LNK2019:函数 _fprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) 中引用了无法解析的外部符号 ___mingw_vfprintf
错误 2 错误 LNK2001:无法解析的外部符号 ___mingw_vfprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-misc.o)
错误 3 错误 LNK2001:无法解析的外部符号 _gpg_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ecc.o)
错误 4 错误 LNK2019:函数 __gcry_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) 中引用了无法解析的外部符号 _gpg_strerror
错误 5 错误 LNK2001:无法解析的外部符号 _gpg_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-misc.o)
错误 6 错误 LNK2001:无法解析的外部符号 _gpg_strerror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(md.o)
错误 7 错误 LNK2001:无法解析的外部符号 _gpg_strerror D:\VidPlaya_offline\TryingToInincludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-fips.o)
错误 8 错误 LNK2019:函数 __gcry_strsource D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) 中引用了无法解析的外部符号 _gpg_strsource
错误 9 错误 LNK2019:函数 _do_malloc D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o) 中引用了无法解析的外部符号 _gpg_err_set_errno
错误 10 错误 LNK2001:无法解析的外部符号 _gpg_err_set_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-stdmem.o)
错误 11 错误 LNK2001:无法解析的外部符号 _gpg_err_set_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-secmem.o)
错误 12 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-module.o)
错误 13 错误 LNK2019:函数 _gpg_err_make_from_errno D 中引用的无法解析的外部符号 _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-global.o)
错误 14 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-sexp.o)
错误 15 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToInincludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(md.o)
错误 16 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_errno D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(primegen.o)
错误 17 错误 LNK2019:函数 _sprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-sexp.o) 中引用了无法解析的外部符号 ___mingw_vsprintf
错误 18 错误 LNK2001:无法解析的外部符号 ___mingw_vsprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ac.o)
错误 19 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(primegen.o)
错误 20 错误 LNK2019:函数 _progress D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(dsa.o) 中引用了无法解析的外部符号 _gpg_err_code_from_syserror
错误 21 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ecc.o)
错误 22 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(random-fips.o)
错误 23 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToInincludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(mpicoder.o)
错误 24 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(cipher.o)
错误 25 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToInincludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(pubkey.o)
错误 26 错误 LNK2001:无法解析的外部符号 _gpg_err_code_from_syserror D:\VidPlaya_offline\TryingToInincludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(kdf.o)
错误 27 错误 LNK2019:函数 __gcry_pk_get_keygrip D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(pubkey.o) 中引用了无法解析的外部符号 _snprintf
错误 28 错误 LNK2001:无法解析的外部符号 _snprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(md.o)
错误 29 错误 LNK2001:无法解析的外部符号 _snprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(ecc.o)
错误 30 错误 LNK2001:无法解析的外部符号 _snprintf D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(rndw32.o)
错误 31 错误 LNK2019:函数 _init_pool D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(libgcrypt_la-secmem.o) 中引用了无法解析的外部符号 _getpagesize
错误 32 错误 LNK2019:函数 _x931_get_dt D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(random-fips.o) 中引用的无法解析的外部符号 _gettimeofday
错误 33 错误 LNK2001:无法解析的外部符号 _gettimeofday D:\VidPlaya_offline\TryingToInincludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\libvlccore\libgcrypt.lib(random-csprng.o)
错误 34 错误 LNK1120:10 个无法解析的外部 D:\VidPlaya_offline\TryingToInincludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\Release\libvlccore.dll
错误 89 错误 LNK2001:无法解析的外部符号“public: virtual struct QMetaObject const * __thiscall UpdateDialog::metaObject(void)const ” (?metaObject@UpdateDialog@@UBEPBUQMetaObject@@XZ) D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\lib_plugin \帮助.obj
错误 90 错误 LNK2001: 无法解析的外部符号“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
错误 91 错误 LNK2001:无法解析的外部符号“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
错误 92 错误 LNK1120:3 个无法解析的外部 D:\VidPlaya_offline\TryingToIncludeUpdateFacility\Vidplaya_Plugin_EmbeddedUpdate\vlcwin\Release\plugins\lib_plugin.dll
任何与此相关的建议都会有所帮助。
好吧,基本上你必须找到具有该符号的库 - .lib 或 .a(取决于平台)文件。静态库在链接到可执行文件或共享库之前不会解析其符号,因此您可能有一个未解析所有符号的静态库。您可以使用第 1 点中提到的工具来验证这一点 - 当您转储符号时,未解析的符号将具有U
信摆在他们面前。当您将它们链接到应用程序中时,链接器必须解析所有符号,如果缺少某些内容,则会出现未解决的引用错误。你基本上有两个选择:
1)使用符号转储实用程序,例如nm
(Windows 上的 Linux 和 MinGW)或dumpbin
(Windows 上的 Visual Studio)和 grep 查找符号(如果您有一个充满库的目录,您可以编写一个脚本为每个文件执行此操作),然后当您知道正确的库文件时,将您的代码链接到它(再次取决于在平台上-l<library name>
Linux 和 MinGW windows 的切换,添加#pragma comment(lib, "<library name>")
或通过 Visual Studio 中的属性页指定库。
2)如果您有所有库的源代码,您可以对函数的定义进行纯文本搜索,然后链接到具有源代码的库。
3) 即使您已经链接到正确的库但 C 和 C++ 代码混合在一起,这些问题也可能会出现。具有 C 接口的库应该将其标头包含在一个extern "C"
块,以便当只有具有 C 名称的函数可用时,链接器不会尝试查找具有 C++ 名称的函数。对于 FFmpeg 和其他大型开源项目的初学者来说,这是一个常见问题。
UPDATE
至于原来的问题__mingw_vfprinf
— 您将使用 MinGW 编译的代码与 Visual Studio 链接起来有点奇怪,我想说您最好也在您的项目中使用 MinGW,但正如类似的话题 http://mingw.5.n7.nabble.com/undefined-reference-with-mingw-vfprintf-td17020.html这可能是由于缺少libmingwex.a
。如果您有 MinGW 工具链,请找到该文件所在的位置,通过 Visual Studio 属性页将该目录添加到链接器搜索目录中,然后添加libmingwex.a
作为项目的链接器输入,通过 Visual Studio 属性页或通过上面提到的编译指示。如果您没有 MinGW 工具链,那么您应该下载它,但您需要获得正确的平台 - 但我想既然您在某个地方获得了该库,您就知道它是 32 位还是 64 位。
UPDATE 2
以下是 MinGW 包管理器的示例屏幕截图,显示了哪个包包含该库:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)