Hi everyone,
maybe i ask the question in wrong place, because the question is more likely a embedded system (gumstix) problem. but i try it any way.
I want my Qt program, which includes a sqlite database, running in gumstix overo system.
first of all, i finished my program in ubuntu. then, cross compile it to gumstix.
here is part of my program:
// create new database
dbName
= QString(QApplication::applicationDirPath()).
append("/database/I-" + sDate.
toString("MMyyyy") + ".db");
mydb.setDatabaseName(dbName);
if (!QFile::exists(dbName
)) {
mydb.open();
query.exec("create table c1Params (ID int primary key unique, "
"Time QString, Status int, Spare QByteArray)");
mydb.close();
}
if (!mydb.open())
{
QMessageBox::warning(this, tr
("Unable to open database"), tr
("An error occurred while " "opening the connection: ") + m4db.lastError().text());
return;
}
// create new database
QDate sDate = QDate::currentDate();
QString dbName;
dbName = QString(QApplication::applicationDirPath()).append("/database/I-" + sDate.toString("MMyyyy") + ".db");
mydb = QSqlDatabase::addDatabase("QSQLITE");
mydb.setDatabaseName(dbName);
if (!QFile::exists(dbName))
{
mydb.open();
QSqlQuery query;
query.exec("create table c1Params (ID int primary key unique, "
"Time QString, Status int, Spare QByteArray)");
mydb.close();
}
if (!mydb.open())
{
QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
"opening the connection: ") + m4db.lastError().text());
return;
}
To copy to clipboard, switch view to plain text mode
program works fine in ubuntu. meanwhile, i can use command line to do all sqlite3 command in gumstix.
however, when i run program in gumstix, i got error message shows on the gumstix touch screen:
Unable to open database, An error occurred while opening the connection.
this indicate that 'mydb' has not been able to created.
the following message is shown in on gumstix prompt.
root@overo:~# ./mypro -qws
Trying to open File
Opened File succesfully
Segmentation fault
root@overo:~#
root@overo:~# ./mypro -qws
Trying to open File
Opened File succesfully
QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers:
QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
Segmentation fault
root@overo:~#
To copy to clipboard, switch view to plain text mode
does anyone have idea how to solve this problem?
thanks in advance
Bookmarks