LNK1120& LNK2019错误

时间:2014-04-05 19:48:37

标签: c++ c

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

  

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

     

错误2错误LNK1120:1个未解析的外部部件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;
    }

1 个答案:

答案 0 :(得分:0)

您需要链接CryptoAPI库。您可以从链接器的项目属性(Configuration Properties&gt; Linker&gt; Input&gt; Additional dependencies)或带有{{1}的代码执行此操作指令。

#pragma