Results 1 to 6 of 6

Thread: Yet Another QMYSQL driver not loaded issue

  1. #1
    Join Date
    Sep 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Yet Another QMYSQL driver not loaded issue

    Hi All

    Running Red Hat Enterprise Linux Server release 5.4 (Tikanga) with Qt4.7.0 32-bit and downloaded and yum installed MySQL-embedded-community-5.1.50-1.rhel5.i386.rpm (wish to embed MySQL)

    Followed all the directions as set out here (with some path changes and the necessary changes for the embedded lib):

    http://doc.trolltech.com/4.7-snapshot/sql-driver.html

    This is what I have in ../../../src/plugins/sqldrivers/mysql

    Qt Code:
    1. [root@localhost mysql]# ll
    2. total 29204
    3. -rwxr-xr-x 1 root root 29686009 Sep 8 13:01 libqsqlmysql.so
    4. -rw-r--r-- 1 root root 2798 Jun 2 04:03 main.cpp
    5. -rw-r--r-- 1 root root 10244 Sep 8 13:01 main.o
    6. -rw-r--r-- 1 root root 8947 Sep 8 12:58 Makefile
    7. -rw-r--r-- 1 root root 2641 Sep 8 13:01 moc_qsql_mysql.cpp
    8. -rw-r--r-- 1 root root 5940 Sep 8 13:01 moc_qsql_mysql.o
    9. -rw-r--r-- 1 root root 585 Jun 2 04:03 mysql.pro
    10. -rw-r--r-- 1 root root 2412 Sep 8 13:01 qsql_mysql.moc
    11. -rw-r--r-- 1 root root 79112 Sep 8 13:01 qsql_mysql.o
    12. -rw-r--r-- 1 root root 204 Jun 2 04:03 README
    To copy to clipboard, switch view to plain text mode 

    and the following in ../../..//plugins/sqldrivers

    Qt Code:
    1. [root@localhost sqldrivers]# ll
    2. total 10960
    3. -rwxr-xr-x 1 root root 424302 Jun 2 14:18 libqsqlite2.so
    4. -rwxr-xr-x 1 root root 1601752 Jun 2 14:17 libqsqlite.so
    5. -rwxr-xr-x 1 root root 8602384 Sep 8 13:01 libqsqlmysql.so
    6. -rwxr-xr-x 1 root root 537311 Jun 2 14:18 libqsqlpsql.so
    To copy to clipboard, switch view to plain text mode 

    Running the following code (having included Qt += sql in the project file)

    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QtSql/QSqlDatabase>
    3. #include <QtSql/QSqlError>
    4. #include <QStringList>
    5. #include <QtDebug>
    6.  
    7. int main( int argc, char **argv )
    8. {
    9. QCoreApplication app( argc, argv );
    10. //app.addLibraryPath("/opt/qtsdk-2010.04/qt/plugins/sqldrivers");
    11. qDebug() << QSqlDatabase::drivers();
    12. QSqlDatabase db( QSqlDatabase::addDatabase( "QMYSQL" ) );
    13. qDebug() << db.lastError();
    14. qDebug() << app.libraryPaths();
    15. }
    To copy to clipboard, switch view to plain text mode 

    Produces the following

    Qt Code:
    1. ("QSQLITE")
    2. QSqlDatabase: QMYSQL driver not loaded
    3. QSqlDatabase: available drivers: QSQLITE
    4. QSqlError(-1, "Driver not loaded", "Driver not loaded")
    5. ("/opt/qtsdk-2010.04/qt/plugins")
    To copy to clipboard, switch view to plain text mode 

    As it is obvious that QMYSQL is still not loaded, I am at a loss as to what to do next. Have spent two days on the net already, looking for solutions.

    It seems to me as if the library compiled correctly and that the include path is fine, yet Qt still doesn't pick up the plugin. What could I have missed?

    Any help will be greatly appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Yet Another QMYSQL driver not loaded issue

    Why does the installed size differ?

    Qt Code:
    1. -rwxr-xr-x 1 root root 29686009 Sep 8 13:01 libqsqlmysql.so
    2. -rwxr-xr-x 1 root root 8602384 Sep 8 13:01 libqsqlmysql.so
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Yet Another QMYSQL driver not loaded issue

    Could it be because the debug info is stripped during "make install"? I removed, deleted, uninstalled and destroyed all the existing files, libs and directories and went through the whole procedure again, but still no luck. Everything exactly the same.

    I can use SQLite, but when it comes to things like these I'm a bit of an irritation to myself, I really want to know WHY it doesn't work when everything says it should!

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Yet Another QMYSQL driver not loaded issue

    I don't think make install strips the binary.

    Another problem that might occure is a difference in either compiler or used libraries.
    In other words, the Qt library might be compiled with a Microsoft compiler and you compile it with gcc for example.

  5. #5
    Join Date
    Sep 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Yet Another QMYSQL driver not loaded issue

    I'm going to try and run configure and see if that produces better results than the manual install...Will also have a look into the compilers, but I believe it's all gcc.

    Thanks for the input! Will report back here in a few hours (gmake takes aaaaages on my machine).

  6. #6
    Join Date
    Oct 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows
    Wiki edits
    1

    Default Re: Yet Another QMYSQL driver not loaded issue

    This same thing happened to me. Finally after digging through forums I found something helpful: the QPluginLoader. This doesn't fix anything, but it does have an errorString that can help troubleshoot:

    QPluginLoader *thePlugin = new QPluginLoader("C:/qt/2009.05/qt/plugins/sqldrivers/qsqlmysqld4.dll");
    qDebug() << thePlugin->load();
    qDebug() << thePlugin->isLoaded();
    qDebug() << thePlugin->errorString();

    In my case the error was "module not loaded" so I opened up qsqlmysqld4.dll with the Dependency Editor and it couldn't find libmysql.dll. If you remember this is the dll that comes with MySQL. The final fix was just copying this file (libmysql.dll, not qsqlmysql4.dll) to the folder with my executable in it. Now the QMySQL driver works and I will note that for what I am doing it is almost twice as fast as the QODBC driver.

Similar Threads

  1. QSqlDatabase: QMYSQL driver not loaded
    By earthling in forum Qt Programming
    Replies: 13
    Last Post: 4th December 2010, 15:19
  2. QMYSQL driver not loaded error
    By mr.dct in forum Newbie
    Replies: 1
    Last Post: 1st April 2010, 18:43
  3. QMYSQL driver not loaded
    By cydside in forum Qt Programming
    Replies: 4
    Last Post: 31st March 2010, 02:18
  4. QMYSQL driver not loaded
    By akhila in forum Newbie
    Replies: 1
    Last Post: 22nd February 2010, 18:24
  5. QMYSQL driver not loaded
    By sepehr in forum Qt Programming
    Replies: 12
    Last Post: 11th January 2009, 20:15

Tags for this Thread

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.