qt - How to embed SQLite into a C++ project -


i'm trying embed sqlite project. have included following files directory called lite : sqlite3.dll, sqlite3.h, , sqlite3.lib.

this project:

#include <stdio.h> #include <lite/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); } 

i following errors when run project:

:-1: error: cannot find -lsqlite3d collect2.exe:-1: error: error: ld returned 1 exit status 

what doing wrong?

i'm working in qt. .pro file:

template = app config += console c++11 config -= app_bundle config -= qt  sources += main.cpp  win32:config(release, debug|release): libs += -l$$pwd/lite/ -lsqlite3 else:win32:config(debug, debug|release): libs += -l$$pwd/lite/ -lsqlite3d else:unix: libs += -l$$pwd/lite/ -lsqlite3  includepath += $$pwd/lite dependpath += $$pwd/lite 

since using qt why don't use qt sql module? going save lot of pain, bypass kind of linkage problems adding

qt += sql 

to qt project file, , adding

#include <qtsql> 

to surce files. you'll have lot of model-view classes facilitate integration of database application ui.

this recommended way use sql in qt applications, unless have very specific needs. can have qt use different sql engines under hood (sqlite, mysql,...), qt abstract you.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -