Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: Yet *another* MYSQL drivers not loaded issue

  1. #1
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Yet *another* MYSQL drivers not loaded issue

    Hi,

    I've installed Qt 4.7.2 using the QtSDK installer, and I don't know how to get Qt to build/load the MySQL driver, which i need. I didn't see any config file in the QtSDK directory, and there's no such options given by the wizard. So ./configure -qt-sql-mysql isn't an option, and this thread

    http://www.qtcentre.org/threads/3401...t-loaded-issue

    didn't help me either. How can I get the driver? (I'm currently getting the 'QSqlDatabase: QMYSQL driver not loaded' error.)

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Do you have MySQL client libraries installed?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Yes, should have mentioned that. I have a MySQL database that I can access perfectly well through the Query Browser and via PHP (phpMyAdmind or my own scripts).

    Edit: I've also now tried to install support for mysql with the traditional ./configure method on an installation of 4.7.2 that I downloaded without the installer (creates the folder qt-everywhere-opensource-src-4.7.2). Trying to configure with -qt-sql-mysql, it stops halfway through and gives me this:

    MySQL support cannot be enabled due to functionality tests!
    ...
    If you believe this message is in error you may use the continue
    switch (-continue) to ./configure to continue.

    When I continue, the installation completes but I still don't have MySQL support.
    Last edited by MattPhillips; 13th April 2011 at 16:12.

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    What is the path to MySQL client library?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Wysota,

    I can't find libmyqslclient.so, which a little googling suggested is the relevant library. It's not in /usr or /etc.
    $whereis mysql
    gives me

    mysql: /usr/bin/mysql /etc/mysql /usr/lib/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
    In /usr/lib/mysql/plugin and /usr/lib/mysql/plugin I have ha_innodb_plugin.so.

    The MySQL administrator says the socket for the server instance (which is running) is /var/run/mysqld/mysqld.sock, if that helps.

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Without libmysqlclient.so you can't access MySQL databases. When I was asking if you had it installed you said yes. So decide whether you have mysql client libraries installed or not. If not then install them.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Hmm, it's not really a 'decision' is it... I wasn't sure whether I had the client libraries installed or not, since I have the MySQL server running and perfectly accessible through other means, in the Ubuntu software center MySQL Client is marked as 'installed', and I haven't had this problem in the past (I've mysql via previous versions of Qt, perhaps on a different version of Ubuntu--I can't be sure). Anyway, I found a package which put libmysqlclient.so.15 and *.16 in /usr/lib. I restarted but Qt still didn't see MySQL.

    Edit: If I try to #include <QMYSQLDriver>, I get 'mysql.h: no such file or directory', deriving from

    Qt Code:
    1. #include <mysql>
    To copy to clipboard, switch view to plain text mode 

    in qsql_mysql.h. Subsequent searching for mysql.h in the file system didn't turn up anything.

    Edit 2: I now have mysql.h in /usr/include/mysql, and the path added to INCLUDEPATH in my .pro file. Also libmysqlclient.a in /usr/lib, and similarly

    LIBS += -L/usr/lib -lmysqlclient
    Still 'mysql driver not loaded'.

    Edit 3: So now, I tried to install 4.7.2 from the .tar file with configure options -static -release -qt-sql-mysql. It configured ok and then about an hour into the make, failed with

    In function 'global constructors keyed to main':
    main.cpp: (.text+0x1): undefined reference to 'qt_plugin_instance_qsqlite()'
    Last edited by MattPhillips; 18th April 2011 at 06:30.

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Why would you try to include QMYSQLDriver?

    For MySQL plugin to work you need:
    1. MySQL client library called "mysqlclient"
    2. Qt MySQL plugin which either is already built and ready or to build it you need:
    a) Qt source code
    b) MySQL development files (headers)
    c) MySQL client library (called "mysqlclient")

    ... and possibly dependencies of any of those. In addition to that if you run Windows you need to make sure you build the plugin in the appropriate mode (debug vs release).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Ok so I rebuilt 4.7.2 from the .tar file but this time without the -static option, as some searching indicated that sqlite was incompatible with a static build. After doing this, the mysql drivers were available with that version of Qt (hooray!). So clearly all the needed dev files are available. Qt Docs indicate I should find a mysql.pro file in src/plugins/sqldrivers/mysql, but I found one only in the QtSDK/QtSources/4.7.1 directory, not QtSDK/QtSources/4.7.2. Simply copying it into 4.7.2 and trying to build there didn't work, too many other files were missing. So I built the 4.7.1 version, and when I rebuilt and ran my program using the installer's version of Qt, I still got QMYSQL driver not loaded. So I can survive for now but the installer was supposed to make life easier I thought... I'd still like to know what's wrong there.

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    You missed out a very important piece of information in your earlier posts - that you're building Qt in static mode. You can't use regular plugins with statically built Qt. You need the static flavour of plugins that your application needs to be explicitly linked against.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Using the Qt installer, the option is never presented as to whether to build dynamically or statically, but judging by the size of the executable it's clearly a dynamic build. So how do I build the drivers for it?

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Quote Originally Posted by MattPhillips View Post
    So how do I build the drivers for it?
    As far as I remember it comes with MySQL plugin already built. If not, follow the procedure described in the docs.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Well, this is a little late for a followup but as the Qt Updater recently broke my installation of Qt (see previous post of mine) I decided to download and install 4.7.3 (online installer), and now I'm faced with this 'QMYSQL drivers not loaded' nightmare all over again.

    If not, follow the procedure described in the docs.
    Ha! If only. I went to the doc page and neither set of commands given there worked. Specifically,

    cd $QTDIR/src/plugins/sqldrivers/mysql
    qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
    make
    gave me

    In file included from main.cpp:44:
    ../../../sql/drivers/mysql/qsql_mysql.h:52:19: error: mysql.h: No such file or directory
    and

    cd $QTDIR/src/plugins/sqldrivers/mysql
    make install
    gave me

    *** No rule to make target `install'. Stop.
    I note that $QTDIR isn't defined on my system (so I had to type in the full path, namely QtSDK/QtSources/4.7.3) but I don't see how that should mean anything, I just mention it for completeness.

    Has anybody who installed Qt from the online (or offline) installer successfully managed to access the QMYSQL database (or any database besides QSqlLite)? Or do I have to cross my fingers and build Qt from the .tar file again?

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    You have MySql installed, right?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Yes, up until the reinstall I had been using Qt and MySQL together, successfully, as described in post #9. Connecting to databases, running queries, etc. I also am able to access MySQL databases through independent tools (MySQL Administrator and MySQL Query Browser). I can rebuild from the .tar file as in #9 but that takes hours and it seems ridiculous to have to go through that just to get the MySQL drivers.

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Is mysql.h present in /usr/local/include?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #17
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    No I didn't, I had it in /usr/include/mysql. When I put it in /usr/local/include and re-ran the qmake/make commands, I got

    g++ -c -pipe -O2 -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I/usr/local/include -I. -o main.o main.cpp
    In file included from ../../../sql/drivers/mysql/qsql_mysql.h:52,
    from main.cpp:44:
    /usr/local/include/mysql.h:70:27: error: mysql_version.h: No such file or directory
    /usr/local/include/mysql.h:71:23: error: mysql_com.h: No such file or directory
    /usr/local/include/mysql.h:72:24: error: mysql_time.h: No such file or directory
    /usr/local/include/mysql.h:74:70: error: my_list.h: No such file or directory
    /usr/local/include/mysql.h:132:21: error: typelib.h: No such file or directory
    /usr/local/include/mysql.h:147:22: error: my_alloc.h: No such file or directory
    In file included from ../../../sql/drivers/mysql/qsql_mysql.h:52,
    from main.cpp:44:
    /usr/local/include/mysql.h:115: error: use of enum ‘enum_field_types’ without previous declaration
    /usr/local/include/mysql.h:153: error: ‘MEM_ROOT’ does not name a type
    /usr/local/include/mysql.h:260: error: ‘NET’ does not name a type
    /usr/local/include/mysql.h:266: error: ‘MEM_ROOT’ does not name a type
    /usr/local/include/mysql.h:285: error: ‘SCRAMBLE_LENGTH’ was not declared in this scope
    /usr/local/include/mysql.h:302: error: expected ‘;’ before ‘*’ token
    /usr/local/include/mysql.h:326: error: ‘MEM_ROOT’ does not name a type
    /usr/local/include/mysql.h:350: error: ‘NET’ does not name a type
    /usr/local/include/mysql.h:518: error: use of enum ‘mysql_enum_shutdown_level’ without previous declaration
    /usr/local/include/mysql.h:525: error: use of enum ‘enum_mysql_set_option’ without previous declaration
    /usr/local/include/mysql.h:672: error: ‘NET’ has not been declared
    /usr/local/include/mysql.h:683: error: use of enum ‘enum_field_types’ without previous declaration
    /usr/local/include/mysql.h:695: error: ‘MEM_ROOT’ does not name a type
    /usr/local/include/mysql.h:696: error: ‘LIST’ does not name a type
    /usr/local/include/mysql.h:724: error: ‘MYSQL_ERRMSG_SIZE’ was not declared in this scope
    /usr/local/include/mysql.h:725: error: ‘SQLSTATE_LENGTH’ was not declared in this scope
    /usr/local/include/mysql.h:767: error: use of enum ‘enum_server_command’ without previous declaration
    make: *** [main.o] Error 1

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    How about passing /usr/local/include/mysql instead of /usr/local/include into configure? The problems you are having are strictly related to files and compilers and not to Qt and MySql.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. The following user says thank you to wysota for this useful post:

    MattPhillips (23rd June 2011)

  20. #19
    Join Date
    Aug 2009
    Posts
    140
    Thanks
    22
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Thanks wysota, your suggestion was right on track, I should have worked a little harder to get those paths right first. Though the original location of mysql.h was /usr/local/mysql, I don't have a /usr/local/include/mysql folder, so that's what I passed to configure. And I was able to run 'make' unproblematically. However the drivers still don't work. When I cd and run make install I get this:

    install -m 755 -p "libqsqlmysql.so" "/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so"
    strip --strip-unneeded "/usr/lib/qt4/plugins/sqldrivers/libqsqlmysql.so"
    This is printed and the console returns to the prompt immediately. I have this in my .pro file, which I've double-checked is correct:

    Qt Code:
    1. INCLUDEPATH += /usr/include/mysql
    2. LIBS += -L/usr/lib -lmysqlclient -lmysqlclient_r
    To copy to clipboard, switch view to plain text mode 

    But when I try run my program--which worked fine under my previous Qt install--I get the same 'driver not loaded' error as before.

    Edit: In the directory $QTDIR/src/plugins/sqldrivers/mysql I now have (due to the make) libqsqlmysql.so. I put in a link to libmysqlclient.so, still didn't work.


    Added after 9 minutes:


    Got it! I went in and put a link to libqsqlmysql.so in QtSDK/Desktop/Qt/473/gcc/plugins/sqldrivers, and it worked. Is it specified *anywhere* in the documentation that you need to do this? Seriously Qt...
    Last edited by MattPhillips; 23rd June 2011 at 05:05.

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

    Default Re: Yet *another* MYSQL drivers not loaded issue

    Lol... You didn't tell configure where to put your Qt installation so it put the driver in the default location. Please don't blame Qt, you're the only one to blame here, honestly.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Mysql drivers
    By thahir1986 in forum Newbie
    Replies: 2
    Last Post: 26th October 2010, 08:07
  2. Building MySQL QT Drivers on Windows XP
    By cia.michele in forum Newbie
    Replies: 6
    Last Post: 16th August 2010, 19:54
  3. Installing QT in windows with mysql drivers
    By roncriss in forum Installation and Deployment
    Replies: 0
    Last Post: 20th November 2009, 04:45
  4. mysql drivers for QT-4.5.2
    By jsmith in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2009, 12:33
  5. Mysql drivers install problems
    By cyberboy in forum Qt Programming
    Replies: 20
    Last Post: 2nd February 2008, 15:11

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.