Results 1 to 6 of 6

Thread: Loading SQLite plugin. Again!

  1. #1
    Join Date
    Jul 2009
    Location
    Italy, Pieve Ligure (GE)
    Posts
    55
    Thanks
    7
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Loading SQLite plugin. Again!

    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.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Loading SQLite plugin. Again!

    You shouldn't have to have anything other than:
    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    in your project.pro file to get all the correct paths to build and run the application in the Qt SDK environment.

  3. #3
    Join Date
    Jul 2009
    Location
    Italy, Pieve Ligure (GE)
    Posts
    55
    Thanks
    7
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Loading SQLite plugin. Again!

    Quote Originally Posted by ChrisW67 View Post
    You shouldn't have to have anything other than:
    Qt Code:
    1. QT += sql
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. QStringList drivers = QSqlDatabase::drivers ();
    To copy to clipboard, switch view to plain text mode 
    only reports: "QMYSQL3" and "QMYSQL", no "QSQLITE" and when I try:
    Qt Code:
    1. m_db = QSqlDatabase::addDatabase("QSQLITE");
    2. m_db.setDatabaseName(strFileName);
    3. m_bValid = (m_db.open() && m_db.isValid());
    To copy to clipboard, switch view to plain text mode 
    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.

  4. #4
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    1

    Default Re: Loading SQLite plugin. Again!

    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/b...ions-qt-1.html

  5. #5
    Join Date
    Jul 2009
    Location
    Italy, Pieve Ligure (GE)
    Posts
    55
    Thanks
    7
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Loading SQLite plugin. Again!

    Quote Originally Posted by Goldmmbr View Post
    did you complile QT with "-qt-sql-<sqlite>"
    http://doc.trolltech.com/qtopia4.2/b...ions-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.
    Last edited by miwarre; 11th November 2009 at 15:42.

  6. #6
    Join Date
    Jul 2009
    Location
    Italy, Pieve Ligure (GE)
    Posts
    55
    Thanks
    7
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Loading SQLite plugin. Again! [SOLVED!]

    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.

Similar Threads

  1. problem loading custom plugin on Qt Designer 4
    By raman_31181 in forum Qt Tools
    Replies: 18
    Last Post: 26th September 2008, 10:42
  2. Plugin Loading and Signal Handling in Qt4
    By liquid in forum Newbie
    Replies: 4
    Last Post: 25th January 2008, 10:53
  3. How to debug plugin loading?
    By yosefm in forum Qt Tools
    Replies: 1
    Last Post: 1st November 2007, 13:02
  4. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 15:13
  5. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 20:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.