PDA

View Full Version : Loading SQLite plugin. Again!



miwarre
6th November 2009, 21:06
I know this has been asked before: I searched the forum and most of what I found I did not understand, something probably does not applies, and the little I tried did not work. So, I'm asking.

*) Ubuntu jaunty.
*) I have installed qtsdk-2009.04.1 (pre-compiled binaries, in the default dir /opt) without building anything myself.
*) I am trying to use the QSQLITE plugin in an app. Static or shared would be the same at the moment, but I settled for run-time loaded plugin, assuming it would be quicker.

A: I have added the following line to the .pro:

QTPLUGIN += qsqlite

and I got the error: /usr/bin/ld: cannot find -lqsqlite

Now, there are two copies of libqsqlite.so in my system:

1) /opt/qtsdk-2009.04/bin/sqldrives/libqsqlite.so (433.5 KB, 5 Oct. 2009)
2) /opt/qtsdk-2009.04/qt/plugins/sqldrives/libqsqlite.so (1.4 MB, 29 Sep. 2009)

(there is also a dir /usr/lib/qt4/plugins/sqldrivers which only contains libqsqlmysql.so, 58.1 KB, 10 Sep. 2009).

B: Assuming 2) is the correct one, I added to the .pro:

LIBS += -L/opt/qtsdk-2009.04/qt/plugins/sqldrivers

and the app compiled without errors.

But, when I launch it (from Qt Creator or from a command line), it aborts with the error: error while loading shared libraries: libqsqlite.so: cannot open shared object file: No such file or directory

C: So, according to some forum posts, I tried adding in the app dir a folder "sqldrivers" and I copied the above file 2) in it. But running the app, results in the same error.

The above process already took the best part of two days and I am inclined to give up. So, now what? Thanks!

M.

ChrisW67
8th November 2009, 09:15
You shouldn't have to have anything other than:

QT += sql
in your project.pro file to get all the correct paths to build and run the application in the Qt SDK environment.

miwarre
8th November 2009, 12:28
You shouldn't have to have anything other than:

QT += sql
in your project.pro file to get all the correct paths to build and run the application in the Qt SDK environment.

Thanks, but... I tried so many things that I forgot to mention how it started in the beginning. If I do as you say, yes, everything compiles OK, but then it does not work. For instance:

QStringList drivers = QSqlDatabase::drivers ();
only reports: "QMYSQL3" and "QMYSQL", no "QSQLITE" and when I try:

m_db = QSqlDatabase::addDatabase("QSQLITE");
m_db.setDatabaseName(strFileName);
m_bValid = (m_db.open() && m_db.isValid());

m_bValid is always false and no DB operation succeeds (note: the above code works under Windows...).

The SQLite library is there, twice (see prev. post)! How can I convince Qt to notice it?

Thanks,
M.

Goldmmbr
9th November 2009, 16:11
did you complile QT with "-qt-sql-<sqlite>"


-qt-sql-<driver> ... Enable a SQL <driver> in the QtSql library, by default
none are turned on.

http://doc.trolltech.com/qtopia4.2/buildsystem/over-configure-options-qt-1.html

miwarre
11th November 2009, 10:42
did you complile QT with "-qt-sql-<sqlite>"
http://doc.trolltech.com/qtopia4.2/buildsystem/over-configure-options-qt-1.html
As I said in my first post, I did not compile anything; I installed the latest SDK version "out of the box".

UPDATED:

I am trying to use QSQLite as a plug-in ("QT += sql" in the .pro file); the code compiles fine and the app starts but the QSQLITE plugin is not found: QSqlDatabase::drivers() only reports QMYSQL3 and QMYSQL.

The library is there, several times:
1) /usr/lib/qt4/plugins/sqldrivers/libqsqlite.so (copy of 2)
2) /opt/qtsdk-2009.04/qt/plugins/sqldrivers/libqsqlite.so
3) /opt/qtsdk-2009.04/bin/sqldrivers/libqsqlite.so

and I have also added in the build directory a "sqldrivers" sub-directory where I copied either 2) or 3).

I tried both in debug mode and in release mode, just in case... In no case, the plugin became available.

So, the question is still: How can I convince Qt to notice that the QSQLite library is there?

Thanks,
M.

P.S.: the link you quotes might be outdated: now at least two MySQL drivers are enabled by default.
P.P.S.: the setup described above works with the Windows version of the same SDK out-of-the-box.

miwarre
12th November 2009, 11:23
Thanks to everybody for the suggestions. It turned out it was an installation/configuration problem.

After
* un-installing the whole Qt SDK,
* removing a hodge-podge of Qt-related old stuff (mostly in /usr, no idea where they were from),
* re-installing Qt SDK,
* properly configuring user $PATH and checking QtCreator is able to auto-detect the proper library (I thought I did, but evidently not correctly or not completely)...

...well, now everything works as it should and "QT += sql" is indeed enough for QSQLITE to be found and active.

Thanks!
M.