Zimice
Zimice

Reputation: 37

File not found while using sqlite3.h library while programming in C

I am having a problem in windows 10 in VS Code while using sqlite3.I have added all the files from this website(https://github.com/LuaDist/libsqlite3/blob/master/sqlite3.h) to folder with my main.c and where is my test.db.Error I am getting while defaulty launching code via coderunner is :

main.c:2:21: fatal error: sqlite3.h: No such file or directory #include ^ compilation terminated.

Here is my code:

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

int main(int argc, char* argv[]) {
   sqlite3 *db;
   char *zErrMsg = 0;
   int rc;

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

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

All help is appreciated

Upvotes: 1

Views: 3711

Answers (1)

Zimice
Zimice

Reputation: 37

I am very sorry I have found out solution.I had to change #include <sqlite3.h> to

#include "sqlite3.h"

and place sqlite3.c into folder with my main.c .And to compile this code I had to write: gcc main.c sqlite3.c

Upvotes: 2

Related Questions