How does one go about determining how to resolve unresolved externals when linking Win32 Visual C++ programs? Here’s what I do…
First, you’ll get a link error report such as this:
…
ChilkatDbgDll.lib(CryptoSP.obj) : error LNK2001: unresolved external symbol __imp__CryptAcquireContextA@20
ChilkatDbgDll.lib(Hashing.obj) : error LNK2019: unresolved external symbol __imp__CryptGetHashParam@20 referenced in function "public: bool __thiscall Hashing::hashSha1(class DataBuffer const &,class DataBuffer &,class LogBase &)" (?hashSha1@Hashing@@QAE_NABVDataBuffer@@AAV2@AAVLogBase@@@Z)
ChilkatDbgDll.lib(Hashing.obj) : error LNK2019: unresolved external symbol __imp__CryptDestroyHash@4 referenced in function "public: bool __thiscall Hashing::hashSha1(class DataBuffer const &,class DataBuffer &,class LogBase &)" (?hashSha1@Hashing@@QAE_NABVDataBuffer@@AAV2@AAVLogBase@@@Z)
…
There are a few unresolveds in this short list:
CryptAcquireContextA
CryptGetHashParam
CryptDestroyHash
(ignore the "__imp__" and the garbage after "@", which is just C++ name mangling).
Functions ending with an "A" are ANSI versions of the function, whereas functions ending in "W" are Unicode versions. Drop the "A" or "W", so we have this:
CryptAcquireContext
CryptGetHashParam
CryptDestroyHash
Go to a search engine (Yahoo, Microsoft, Google, etc.) and search for the function. You might also add "site:microsoft.com" to your search terms to restrict the search to Microsoft’s site.
You’re looking for the MSDN result page for the Windows SDK. For example, the page for CryptAcquireContext is:
http://windowssdk.msdn.microsoft.com/en-us/library/ms723945.aspx
Scroll to the bottom of the page where you’ll find a "Requirements" section. This table will tell you the library that is required. If it is not a standard library included when you create the VC++ project, you’ll need to add it to your list of link libs.