與QT5

2017-07-22 61 views
0

使用SQLite我在Ubuntu與QT5

#include <sqlite3.h> /* sqlite3 */ 


void prog::on_pushButton_clicked() 
{ 
    sqlite3 *db; 
    int rc = sqlite3_open("/home/profile.sqlite", &db); 
    if (rc != SQLITE_OK) { 
     fprintf(stderr, "Cannot open database: %s\n", 
       sqlite3_errmsg(db)); 
     sqlite3_close(db);  
    } 
} 

我得到這個錯誤:

enter image description here

+0

您是否將庫包含在.pro中?你的操作系統是什麼? – eyllanesc

+0

@eyllanesc Ubuntu和沒有 – Julien

回答

3

爲了使用SQLite庫在Linux(Ubuntu的),您必須安裝以下庫:

sudo apt-get install libsqlite3-dev 

然後,您可以使用以下語句將它添加到.pro文件中:

LIBS += -lsqlite3 

Qt同時也提供了管理多個數據庫,包括sqliteQtSql模塊,我建議您閱讀以下有關它: