I am trying to connect to a local SQLite database I have for a school project. We are free to use whatever language we want and I use Qt all the time at work, so I decided to use this over Java for me application. I thought by following the documentation, this wouldn't be too difficult but I am having problems. I am running Qt Creator 2.0.1 on Windows 7 with Qt 4.7.0. The following line in my CPP file causes an error:
QSqlDatabase database = QSqlDatabase::addDatabase( "QSQLITE" );
To copy to clipboard, switch view to plain text mode
The compilation error I get is:
:: error: collect2: ld returned 1 exit status
Commenting this line out lets the code compile successfully. The whole function it is in is this:
bool MainWindow::connectToDatabase( )
{
return true;
}
bool MainWindow::connectToDatabase( )
{
QSqlDatabase database = QSqlDatabase::addDatabase( "QSQLITE" );
return true;
}
To copy to clipboard, switch view to plain text mode
Obviously this function will have more in it later, and I will use a class variable instead of the local object, but if I can't get this simple statement to compile, no sense trying more complex things, yet.
Any ideas why my code wouldn't compile with this simple line? It is straight out of the documentation with the SQLite driver which from what I understand would have been created by default when I installed Qt Creator.
Thanks for your help!
Bookmarks