Results 1 to 5 of 5

Thread: Link problems with static MySQL plugin

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Link problems with static MySQL plugin

    Your Qt is compiled in shared mode, so you can't use static plugins. You have to use regular plugins. First verify if you have them in your sqldrivers directory. If so, check if you have libmysqlclient installed as the driver won't work without it.

  2. #2
    Join Date
    Sep 2007
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Link problems with static MySQL plugin

    I have the plugin:

    Qt Code:
    1. $ ls /usr/lib/qt4/plugins/sqldrivers/
    2. libqsqlmysql.so
    To copy to clipboard, switch view to plain text mode 

    And I have libmysqlclient:

    Qt Code:
    1. $ ls /usr/lib/libmysqlclient*
    2. /usr/lib/libmysqlclient.so /usr/lib/libmysqlclient.so.15.0 /usr/lib/libmysqlclient_r.so /usr/lib/libmysqlclient_r.so.15.0
    3. /usr/lib/libmysqlclient.so.15 /usr/lib/libmysqlclient.so.15.0.0 /usr/lib/libmysqlclient_r.so.15 /usr/lib/libmysqlclient_r.so.15.0.0
    To copy to clipboard, switch view to plain text mode 

    I re-read the plugins-howto and found some stuff I missed earlier. Do I actually need to load the plugin manually (instead of just linking against it) with QPluginLoader by declaring an interface and writing some wrapper class to it?

    I made this very simple test which I want to get working.

    Test.cpp:
    Qt Code:
    1. #include <QSqlDatabase>
    2.  
    3. int main(int argc, char** argv)
    4. {
    5. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    6. return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    Test.pro:
    Qt Code:
    1. SOURCES += Test.cpp
    2. QT = sql
    3. QTPLUGIN = qsqlmysql
    4. TARGET = test
    To copy to clipboard, switch view to plain text mode 

    It compiles fine but I run it and it doesn't find any SQL drivers:

    Qt Code:
    1. $ ./test
    2. QSqlDatabase: QMYSQL driver not loaded
    3. QSqlDatabase: available drivers:
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2007
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Link problems with static MySQL plugin

    I actually managed to get it working. Apparently you need to instantiate QApplication (or in this case QCoreApplication) which actually loads the plugins. Nothing in the plugin documentation explicitly states this, but anyhow this works:

    Qt Code:
    1. #include <QSqlDatabase>
    2. #include <QCoreApplication>
    3.  
    4. int main(int argc, char** argv)
    5. {
    6. QCoreApplication app(argc, argv);
    7.  
    8. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    9.  
    10. return 0;
    11. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Link problems with static MySQL plugin

    Yes, plugins are loaded in QCoreApplication constructor (I must have missed the lack of QApplication in your previous code, sorry). By the way ".so" is a shared object, not a static plugin, therefore you're using real plugins, not static ones now.

Similar Threads

  1. Replies: 16
    Last Post: 23rd May 2008, 10:12
  2. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13
  3. Qt4 win opensource + mysql plugin
    By vr in forum Installation and Deployment
    Replies: 3
    Last Post: 25th May 2007, 09:01
  4. MySql plugin driver issues
    By stevey in forum Installation and Deployment
    Replies: 11
    Last Post: 20th September 2006, 13:45
  5. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38

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
  •  
Qt is a trademark of The Qt Company.