Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite: error: C1083: cannot open include file: 'sqlite3.h'

I am following this tutorial on how to implement SQLite in c\c++. However, when compiling the following code:

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

int main(int args, char* argv[]){
    sqlite *db;
    char *zErrMsg = 0;
    int rc;   
    rc = sqlite3_open("database_1.db", &db);
    if(rc){
      fprintf(stderr, "Can't open databse: %s\n", sqlite3_errmsg(db));
      exit(0);
    }else{ 
      fprintf(stderr, "Opened database successfully\n");
    }
    sqlite3_close(db);
}

I receive the following error: C1083: cannot open include file:'sqlite3.h': no such file or directory.

what is the problem and how to solve it.

Note: sqlite was downloaded and installed following this guidance .

like image 671
McLan Avatar asked Feb 22 '26 21:02

McLan


2 Answers

Make sure that your compiler can actually see sqlite3 includes.

In gcc you'd do something like:

g++ main.cpp -I<path_to_sqlite3>

Without "-I" parameter, your #include cannot be seen by the compiler.

If sqlite3.h file is in the same directory as your "main.cpp" file - change your include to:

#include "sqlite3.h"

If you are unsure about the difference, please read: Difference between #include < > and " "

like image 56
Mateusz Jacobsen Avatar answered Feb 24 '26 09:02

Mateusz Jacobsen


Make sure you have the folder with the library headers added to the Additional include directories. See http://msdn.microsoft.com/en-us/library/73f9s62w.aspx.

like image 22
Marius Bancila Avatar answered Feb 24 '26 11:02

Marius Bancila