I wrote the following code snippet in VS2010:
#pragma once
#include "stdafx.h"
#ifndef SECURITY_WIN32
#define SECURITY_WIN32
#endif
#include "windows.h"
#include "sspi.h"
int main( void )
{
ULONG cPackages = 0;
PSecPkgInfo pInfo = NULL;
SECURITY_STATUS stat = EnumerateSecurityPackages(&cPackages, &pInfo);
if (stat == SEC_E_OK)
{
for (ULONG i = 0; i < cPackages; i++)
{
wprintf(L"%s\t%s\n",pInfo[i].Name, pInfo[i].Comment);
}
FreeContextBuffer(pInfo);
}
return 0;
}
but, at the compile time I got the following errors:
error LNK2019: unresolved external symbol _imp_EnumerateSecurityPackagesW@8 referenced in function _main
and
error LNK2019: unresolved external symbol _FreeContextBuffer@4 referenced in function _main
can anyone please help me?
You need to link against Secur32.lib.
Go to Project Properties -> Linker -> Input and add Secur32.lib in the list.
Linking errors "unresolved external symbol", generally, mean that there were no required library (libraries) added to resolve the symbol. In VC++ case you get the symbol without decoration FreeContextBuffer (which will be the function missed), go to http://msdn.microsoft.com and search for this function's related article. In this case it will produce "FreeContextBuffer" as a first result. You then look for the last section "Requirements" and find out what headers would be needed for compiler and libraries (your case) for linker- Secur32.lib. Then, add this library in IDE's Properties -> Linker -> Input. Or with #pragma comment() directive in code.
Hope this will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With