Results 1 to 5 of 5

Thread: MySQL driver on Mac OS X

  1. #1
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default MySQL driver on Mac OS X

    I'm trying to get MySQL working with Qt, but I'm having no luck.

    When I try to open a MySQL connection, QSqlDatabase spits out this error:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

    I'm running Mac OS X 10.6, and have Qt 4.7.2 and MySQL 5.5.10 installed. I've built and tried to install the MySQL plugin (it's definitely in my plugins/sqldrivers directory), but Qt isn't recognising that I've done so (but it is recognising the two other drivers). I've even tried recompiling Qt with these configure arguments:

    ./configure -qt-sql-mysql -I /usr/local/mysql -plugin-sql-mysql

    And it still doesn't work. Can anyone shed some light on this?

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MySQL driver on Mac OS X

    are you running your app from inside QtCreator?
    Make sure you MySQL install includes the development files (lib + include files)
    I'm not too familiar with Mac, but can't you run ldd on the executable to see if all libs can be found?
    On windows, I copied the lib and include files into a folder without spaces before building the plugin:
    Qt Code:
    1. c:/mysql
    2. include/...
    3. lib/...
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2009
    Posts
    104
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: MySQL driver on Mac OS X

    I followed the instruction of compiling the MySQL driver on Mac OS 10.6 but i receive the following error:

    In file included from main.cpp:44:
    ../../../sql/drivers/mysql/qsql_mysql.h:52:19: error: mysql.h: No such file or directory
    In file included from main.cpp:44:
    ../../../sql/drivers/mysql/qsql_mysql.h:108: error: expected `)' before ‘*’ token
    make[1]: *** [debug/main.o] Error 1
    make: *** [debug] Error 2

    could somebody describe in details how exactly must be compile and install MySQL driver on Mac OS X.And also, is there any binary that could be used on random Mac?

  4. #4
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: MySQL driver on Mac OS X

    Quote Originally Posted by schnitzel View Post
    are you running your app from inside QtCreator?
    Make sure you MySQL install includes the development files (lib + include files)
    I'm not too familiar with Mac, but can't you run ldd on the executable to see if all libs can be found?
    On windows, I copied the lib and include files into a folder without spaces before building the plugin:
    Qt Code:
    1. c:/mysql
    2. include/...
    3. lib/...
    To copy to clipboard, switch view to plain text mode 
    I've tried running the app from both inside Qt Creator and normally; it didn't work either way. I have the development files for MySQL.
    I used otool on the generated library file, and got this:
    Qt Code:
    1. libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
    2. libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
    3. /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
    4. /usr/local/Trolltech/Qt-4.7.2/lib/QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.2)
    5. /usr/local/Trolltech/Qt-4.7.2/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.2)
    6. /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
    7. /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 830.0.0)
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by unix7777 View Post
    I followed the instruction of compiling the MySQL driver on Mac OS 10.6 but i receive the following error:

    In file included from main.cpp:44:
    ../../../sql/drivers/mysql/qsql_mysql.h:52:19: error: mysql.h: No such file or directory
    In file included from main.cpp:44:
    ../../../sql/drivers/mysql/qsql_mysql.h:108: error: expected `)' before ‘*’ token
    make[1]: *** [debug/main.o] Error 1
    make: *** [debug] Error 2

    could somebody describe in details how exactly must be compile and install MySQL driver on Mac OS X.And also, is there any binary that could be used on random Mac?
    Have you told it where the MySQL include files are found? My MySQL installation is in /usr/local/mysql, so I put this in my mysql.pro:
    Qt Code:
    1. INCLUDEPATH += /usr/local/mysql/include
    2. LIBS += -L/usr/local/mysql/lib -lmysqlclient_r
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Mar 2009
    Posts
    104
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: MySQL driver on Mac OS X

    it's what i do:

    qmake -o Makefile "INCLUDEPATH+=/Users/Peter/Downloads/mysql-5.5.10-osx10.6-x86_64/include" "LIBS+=-L/Users/Peter/Downloads/mysql-5.5.10-osx10.6-x86_64/lib -lmysqlclient_r" mysql.pro -spec macx-g++

    it's what i got:

    ld: warning: directory not found for option '-L/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib'
    ld: warning: directory not found for option '-F/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib'
    ld: in /Users/jorost/Downloads/mysql-5.5.10-osx10.6-x86_64/lib/libmysqlclient_r.dylib, file too small for architecture x86_64
    collect2: ld returned 1 exit status
    make[1]: *** [libqsqlmysql_debug.dylib] Error 1
    make: *** [debug] Error 2

Similar Threads

  1. source code for odbc driver or MySql driver in arm-embedded-linux
    By sattu in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th January 2011, 10:11
  2. I need MySQL driver for Qt 4.6, WindowsXP(32), MySQL 5.1
    By User_3 in forum Installation and Deployment
    Replies: 7
    Last Post: 15th October 2010, 15:19
  3. MySQL Driver not loaded on PC without Qt
    By KTvsPeacock in forum Installation and Deployment
    Replies: 39
    Last Post: 20th September 2010, 21:37
  4. MySql driver problem
    By stilgar in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2010, 10:26
  5. [qt 4.6] mysql driver
    By vinny gracindo in forum Newbie
    Replies: 0
    Last Post: 25th February 2010, 22:28

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.