'sqlite3_api' was not declared in this sco

2019-03-01 18:20发布

问题:

I've been learning sqlite3 programming in C++ for the first time and this error confounds me and my internet searching abilities.

Here is my code, as far as it gets before throwing an error.

#include <iostream>
#include <sqlite3ext.h>

using namespace std;

int main()
{
    sqlite3 *database;
    int check;

    check = sqlite3_open("introdb3.db", &database); //error is here
}

I'm pretty sure that it has something to do with the libraries that are (or aren't) being linked, but I can't figure out how to make it go properly.

I'm on Ubuntu using code::blocks.

Thanks!!

回答1:

Instead of

#include <sqlite3ext.h> 

write

#include <sqlite3.h> 

The sqlite3ext.h file is only needed if you are going to write an SQLite extension - a custom function, for example. For regular database access, use sqlite3.h.