PDA

View Full Version : Qt embedded compiling with Sqlite3



cooper
22nd February 2011, 03:36
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
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;
}


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
QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers:
QSqlQuery::exec: database not open
QSqlQuery::exec: database not open
Segmentation fault
root@overo:~#


does anyone have idea how to solve this problem?
thanks in advance

ChrisW67
22nd February 2011, 04:20
Deploy the Sqlite plugin along with your application. The plugin lives in the plugins/sqldrivers directory

cooper
22nd February 2011, 20:18
Hi ChrisW67,

Thanks for your reply. I am not sure how can i "Deploy the Sqlite plugin along with your application"?
I copied libqsqlite.so from plugins/sqldrivers directory to /lib in gumstix.
Is this what you meant "deploy"?
but i still got the same error message.

do you mind explain it a little more, please?
Thanks a lot.

EDIT:

I think i can't just simply copy libqslite.so to gumstix. this library is for i386 machine, not for arm processor which is in gumstix. i will compile this library for arm first, then copy it to gumstix.

i will let you know if i can solve this problem.

ChrisW67
22nd February 2011, 23:22
The Qt plugins should be deployed in one of the locations that Qt looks when it needs a plugin: look for Deploying Plugins in Assistant. In the case of the Qsqlite driver you could deploy it in a sub directory "sqldrivers" of the directory containing the program executable or in a plugins/sqldrivers directory of central Qt installation. Similar locations exist for other plugin types.


directory/
my_program_exe
libQtCore.so
...
sqldrivers/
libqsqlite.so
imageformats/
libqjpeg.so


All the deployed libraries and executables must be built for the target processor architecture.

cooper
23rd February 2011, 01:28
great chrisW67,

it is working! thanks for your help.

danielsan
18th February 2015, 10:21
Hi, I have same problem.
I understand chrisW67, but I haven't libsqlite.so, you could show me correct procedure to get and deploy sql lite library?
Thanks