我刚开始初学sqlite,程序这样写的
#include<QtSql/QSqlDatabase>
#include<QtSql/QSqlQuery>
...
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("guo.db");
..
最后提示我
/home/guozhixin/QTli/ini/dialog.cpp:48: undefined reference to `QSqlDatabase::defaultConnection'
/home/guozhixin/QTli/ini/dialog.cpp:48: undefined reference to `QSqlDatabase::addDatabase(QString const&, QString const&)'
/home/guozhixin/QTli/ini/dialog.cpp:48: undefined reference to `QSqlDatabase::~QSqlDatabase()'
/home/guozhixin/QTli/ini/dialog.cpp:49: undefined reference to `QSqlDatabase::setDatabaseName(QString const&)'
/home/guozhixin/QTli/ini/dialog.cpp:49: undefined reference to `QSqlDatabase::~QSqlDatabase()'
/home/guozhixin/QTli/ini/dialog.cpp:49: undefined reference to `QSqlDatabase::~QSqlDatabase()'
请问各位这是怎么回事?
------解决方案--------------------
在pro文件中加入
QT+=sql