其他分享
首页 > 其他分享> > 2019链接错误 – c

2019链接错误 – c

作者:互联网

参见英文答案 > What is an undefined reference/unresolved external symbol error and how do I fix it?                                    32个
我在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; 

}

但是,在编译时我遇到以下错误:

error LNK2019: unresolved external symbol
_imp_EnumerateSecurityPackagesW@8 referenced in function _main

error LNK2019: unresolved external symbol _FreeContextBuffer@4
referenced in function _main

谁能帮帮我吗?

解决方法:

您需要链接Secur32.lib.

转到项目属性 – >链接器 – >在列表中输入并添加Secur32.lib.

标签:c,visual-studio-2010,linker-errors
来源: https://codeday.me/bug/20190729/1573955.html