Unresolved external symbol in libgcrypt.lib

ぃ、小莉子 提交于 2019-12-07 12:22:27

问题


What I have to do if i found Unresolved external symbol in .lib(library) file. If I found unresolved external symbol in .c or .cpp I can fix it. But when i found Unresolved external symbol in .lib(library) file how can i solve this?

In my case i found a linker error like this:

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

Any suggestions regarding this would be helpful.


回答1:


Well, basically you have to find the library - .lib or .a (depending on the platform) file that has that symbol. Static libraries do not resolve their symbols until being linked into an executable or shared library, so you may have a static library that does not have all its symbols resolved. You can verify this using the tools mentioned lower in point 1 - when you dump the symbols the unresolved ones will have a U letter before them. And when you are linking them into your application the linker must resolve all the symbols, and if something is missing you get unresolved reference errors. You basically have two options:

1) Use a symbol dumping utility like nm (Linux and MinGW on Windows) or dumpbin (Visual Studio on Windows) and grep for the symbol (if you have a directory full of libraries you can make a script that does this for each file), and then when you know the correct library file link your code against it (again depends on platform -l<library name> switch for Linux and MinGW windows , add #pragma comment(lib, "<library name>") or specify the library through the property pages in Visual Studio.

2) If you have sources for all the libraries you can do a plain text search for the definition of the function and then linking against the library that has the source should do.

3) These issues may also appear even if you are already linking with the proper library but C and C++ code is being mixed. Libraries with C interface should have their header includes wrapped in an extern "C" block, so that the linker does not try to find a function with the C++ name when only a function with a C name is available. This is a common issue for beginners with FFmpeg and other big open source projects.

UPDATE

As for the original issue with __mingw_vfprinf — it is a bit weird that you are linking code that has been compiled with MinGW with Visual Studio, I'd say you'd be better of using MinGW for your project too, but as suggested in a similar topic this could be cause by missing libmingwex.a. If you have the MinGW toolchain, find where the file is located, add that directory to linker search directories via Visual Studio property pages and add libmingwex.a as a linker input to your project either through the Visual Studio property pages or via the pragma mentioned above. If you don't have the MinGW toolchain then you should download it, but you need to get the right platform — however I guess since you got the library somewhere you know if it is 32bit or 64bit.

UPDATE 2

Here is a sample screenshot of MinGW package manager showing which package contains the library:




回答2:


My experience with other runtime library implementations leads me to suppose that various printf variations are implemented by calling a lower level vprintf form. fprintf was put into thay .o file (why? Isn't that itself a RTL function?) and it needs that helper function. From the name decorations, I expect that's to be found in a mingw system library. I beleive that printf functions are in a supplimental library you need to link with, as it's enhanced over the ones in msvcrt.dll.

So, look for that. Check your versions too, as maybe the lib was built against a different version than you're using now and those details have changed.



来源:https://stackoverflow.com/questions/26401518/unresolved-external-symbol-in-libgcrypt-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!