3

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.

Myanju
  • 1,135
  • 1
  • 11
  • 23
  • 1
    You probably need to import an additional lib containing the missing symbol. – Roger Rowland Oct 16 '14 at 10:30
  • Even i am facing same issue.Any solutions? – adarshaU Oct 16 '14 at 10:36
  • @RogerRowland Thanks for the replay. But how can i get to know the desired/needed .lib file? – Myanju Oct 16 '14 at 10:51
  • 2
    I would guess there is documentation for the library concerned (libgcrypt?) and possibly a config.h that can be checked to make sure you haven't selected inappropriate options. Maybe you should rephrase your question and try to find users of the same library. – Roger Rowland Oct 16 '14 at 11:19
  • @RogerRowland I added #define UPDATE_CHECK in config.h. – Myanju Oct 16 '14 at 11:39
  • @Myanju how? Often google will turn up details. That decorated name is rather specific so I'll bet it finds similar questions to yours. – JDługosz Oct 21 '14 at 14:41

2 Answers2

3

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:

MinGW package manager showing libmingwex.a

JDługosz
  • 5,592
  • 3
  • 24
  • 45
Rudolfs Bundulis
  • 11,636
  • 6
  • 33
  • 71
  • Thanks for the reply. I downloaded mingw and installed. but i didn't find libmingwex.a in the installed directory. Should i have to select the specific package in the mingw installation manager? – Myanju Oct 23 '14 at 11:11
  • Well, I looked into my MinGW installation and I have `libmingwex.a` under `C:\MinGW\lib` and `C:\MinGW\mingw32\lib`, it seems to be a part of the `mingw32-mingwrt` package. See the picture attached to the answer. Btw I did not see the updated question with the additional unresolved symbols, it could require more that just this lib. – Rudolfs Bundulis Oct 23 '14 at 11:51
  • @RudolfsBundulis how can you tell from that post that he's mixing Visual Studio with mingw? – JDługosz Oct 23 '14 at 12:31
  • @jdlugosz well, the `LNK2019` is obviously from Visual Studio linker and if the library he is using has MinGW runtime linked in then most likely it was built with MinGW (except for the very small chance that someone used Visual Studio and linked in MinGW libraries which would make no sense, since all the standard input/output stuff is already in the Visual Studio runtime) – Rudolfs Bundulis Oct 23 '14 at 13:01
  • I didn't know if the other linkers used totally different formatting and error systems or not; it might be formatted to look like MS's on purpose. Also, the LINK.EXE comes with the SDK platform without Visual Studio; since it's meant to be compatible with MSVCRT.dll and system libs, and you want the system headers from the SDK anyway, it might be sensible to use that linker in the toolchain. – JDługosz Oct 23 '14 at 17:52
  • @Myanju any progress with resolving the dependencies coming from MinGW? – Rudolfs Bundulis Oct 24 '14 at 07:35
  • @RudolfsBundulis No it didn't help me. Actually i was compiling VLC 2.1.0 source code in that code software update feature was disabled so i defined define #UPDATE_CHECK in update.h file then i got all these errors. I'm new to this VC++ environment. – Myanju Oct 27 '14 at 07:24
  • @Myanju you could have released this information faster. According to their wiki https://wiki.videolan.org/Win32Compile/ you should build VLC on Windows using MinGW, that is most likely why you get all the issues with Visual Studio. If you have time for chat I can try to help. – Rudolfs Bundulis Oct 27 '14 at 08:52
  • @RudolfsBundulis Sure. We can chat please let me know the suitable time. – Myanju Oct 28 '14 at 06:01
  • @Myanju just start a chat on stackoverflow whenever you are online – Rudolfs Bundulis Oct 28 '14 at 09:12
  • @Rudolfs Bundulis i'm online now. Don't know how to chat, meanwhile i don't have much reputations. – Myanju Oct 28 '14 at 10:22
  • @Myanju i created a chat room http://chat.stackoverflow.com/rooms/63771/vlc-build-on-windows - can you join it? – Rudolfs Bundulis Oct 28 '14 at 10:39
  • @RudolfsBundulis The build is success but The application is failed to launch. program '[6036] VidPlayer.exe: Native' has exited with code -1073741502 (0xc0000142). – Myanju Oct 30 '14 at 10:20
  • @Myanju well then run it under the Visual Studio debugger to see what is going wrong. – Rudolfs Bundulis Oct 30 '14 at 10:21
  • @RudolfsBundulis It's not even going to the WINAPI WinMain(). – Myanju Oct 30 '14 at 12:37
  • Since C0000142 means DLL Initialization Failed you can try to check what DLL's are needed by the exe with dependency walker and make sure they can all be loaded (they are in the DLL search path). – Rudolfs Bundulis Oct 30 '14 at 12:46
  • @RudolfsBundulis Thanks for the suggestion. I loaded the .exe to dependency walker and then found these missing DLLs API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL API-MS-WIN-CORE-WINRT-L1-1-0.DLL API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL DCOMP.DLL GPSVC.DLL – Myanju Oct 30 '14 at 13:59
  • @RudolfsBundulis I don't think that, this will works for me. So i'm planning to implement update(as patches like in google chrome) feature newly. Any suggestions regarding this would be helpful. – Myanju Nov 03 '14 at 13:30
1

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.

JDługosz
  • 5,592
  • 3
  • 24
  • 45
  • Thanks for the reply. How can i link the msvcrt.dll to my project? – Myanju Oct 23 '14 at 11:43
  • You are already. I think you should review the basics of mingw's compile/link architecture and its relationship to the windows system32 library (msvcrt). – JDługosz Oct 23 '14 at 12:19