Answer the question
In order to leave comments, you need to log in
How to connect sqlite to c++ program?
I can not connect sqlite in any way. I am using template code. I try to compile it through the command line, but I get an error: File format not recognized. It can be seen that I did not correctly connect the library to mingw. There are 2 packages. In one sqlite3.c and sqlite3.h. In another sqlite3.dll and sqlite3.def. How to connect them?
#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(0);
} else {
fprintf(stderr, "Opened database successfully\n");
}
sqlite3_close(db);
}
Answer the question
In order to leave comments, you need to log in
You need to pass gcc not a dll file, but a lib (import-library). Generate it with the following command:
The command must be run from Studio com. lines. If you haven't installed it at all, try dlltool:
dlltool help: www.mingw.org/wiki/dlltool
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question