samedi 20 février 2016

sqlite visual studio 2015

I'm trying to make a program using sqlite and visual studio. I've added sqlite3.def, sqlite3.c, sqlite3.h, sqlite3.dll files to the project directory. I've also added THREADSAFE and SQLITE_ENABLE_COLUMN_METADATA in the project settings to the preprocessor definitions and sqlite3.def in Linker -> Input -> Module definition file. I'm trying to compile the following program

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


int main(int argc, char **argv)
{
    sqlite3* db;
    char* zErr;
    int rc;
    char* sql;

    rc = sqlite3_open("test.db", &db);

    if (rc)
    {
        fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
        sqlite3_close(db);
        exit(1);
    }

    sql = "create table episodes( id integer primary key,"
          "                       name text, cid int)";

    rc = sqlite3_exec(db, sql, NULL, NULL, &zErr);

    if (rc != SQLITE_OK)
    {
        if (zErr != NULL)
        {
            fprintf(stderr, "SQL error: %s\n", zErr);
            sqlite3_free(zErr);
        }
    }

    sql = "insert into episodes (name,id) values ('Cinnamon Babka2',1)";
    rc = sqlite3_exec(db, sql, NULL, NULL, &zErr);

    if (rc != SQLITE_OK)
    {
        if (zErr != NULL)
        {
            fprintf(stderr, "SQL error: %s\n", zErr);
            sqlite3_free(zErr);
        }
    }

    sqlite3_close(db);
    return 0;
}

And I get a whole bunch of errors, here are some of them:

LNK2001 unresolved external symbol sqlite3_aggregate_context
LNK2001 unresolved external symbol sqlite3_backup_finish
LNK2001 unresolved external symbol sqlite3_backup_pagecount

My question is how to fix this? Thanks!

Aucun commentaire:

Enregistrer un commentaire