Install sqlite3 library in Gumstix for Qt application

My Qt program will create a database by using sqlite3 plugin app.
The program is working happily in ubuntu, meanwhile, i can use command line to do all sqlite3 command in gumstix. but i got error message when i run it in gumstix.

the error message shows on my touch screen as:

"Unable to open database, An error occurred while opening the connection."

take a look 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");

if (!QFile::exists(dbName))
QSqlQuery query;
query.exec("create table c1Params (ID int primary key unique, "
"Time QString, Status int, Spare QByteArray)");


if (!
QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
"opening the connection: ") + m4db.lastError().text());

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

used 'strace' command to track the error message, and compare stack content between ubuntu and gumstix.

in my ubuntu:
$ strace -o /home/czhang/Desktop/test  ./mypro

stat("/etc/xdg/Trolltech.conf", 0x7fff4c33bec0) = -1 ENOENT (No such file or directory)
stat("/etc/xdg/Trolltech.conf", 0xec71c8) = -1 ENOENT (No such file or directory)
stat("/usr/lib/kde4/plugins/sqldrivers/.", 0xec7348) = -1 ENOENT (No such file or directory)
lstat("/usr/lib/kde4/plugins/sqldrivers/.", 0x7fff4c33c2a0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/qt4/plugins/sqldrivers/.", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/lib/qt4/plugins/sqldrivers", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 22
statfs("/usr/lib/qt4/plugins/sqldrivers", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=9612197, f_bfree=7908029, f_bavail=7419748, f_files=2444624, f_ffree=2135156, f_fsid={490287925, 258803822}, f_namelen=255, f_frsize=4096}) = 0
getdents(22, /* 4 entries */, 32768)    = 128
stat("/usr/lib/qt4/plugins/sqldrivers/", {st_mode=S_IFREG|0644, st_size=73432, ...}) = 0
in gumstix:
$ strace -o /home/root/test  ./mypro

stat64("/etc/xdg/Trolltech.conf", 0xbe916208) = -1 ENOENT (No such file or directory)
stat64("/etc/xdg/Trolltech.conf", 0x205ad0) = -1 ENOENT (No such file or directory)
stat64("/home/root/sqldrivers/.", 0x1ef1b8) = -1 ENOENT (No such file or directory)
lstat64("/home/root/sqldrivers/.", 0xbe916400) = -1 ENOENT (No such file or directory)
write(2, "QSqlDatabase: QSQLITE driver not"..., 40) = 40
write(2, "QSqlDatabase: available drivers:"..., 34) = 34

here is the problem. the Qt in gumstix can not locate the sqlite library interface at directory /home/root/sqldrivers.

"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."

ok, create a dirctory in gumstix
$ mkdir /home/root/sqldrivers
$ scp czhang@x.x.x.x:/build/czhang/qt-everywhere-opensource-src-4.7.0/plugins/sqldrivers/ .


No comments:

Post a Comment