PDA

View Full Version : Qt + Mysql on Mac OS X



P4ulo
27th January 2010, 23:29
Hi guys,

i'm trying build the MySQL plugin for qt, but i have some problems..

in accordance with this site (http://qt.nokia.com/doc/4.0/sql-driver.html#how-to-build-the-plugin-on-unix-and-mac-os-x), these are the steps:


Tell qmake where to find the MySQL header files and shared libraries (here it is assumed that MySQL is installed in /usr/local) and run make:
cd $QTDIR/src/plugins/sqldrivers/mysql
qmake -o Makefile "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient" mysql.pro
make


but, when I put "cd /Developer/Applications/Qt/plugins/sqldrivers/mysql", this is the result:

http://img685.imageshack.us/img685/7445/capturadetela20100127s2.png

Help-me *----*

vishwajeet.dusane
28th January 2010, 13:09
Hi

you must have downloaded qt without sources. you need to have that sqldrivers folder with sources in src/plugins directory. I tried to add that aattachment but i was not able to attach it.

You do not need complete source just that plugins folder in src is enough for you

P4ulo
28th January 2010, 16:30
Can you upload the plugins folder in src for me??
please *-*

boudie
28th January 2010, 20:00
in accordance with this site (http://qt.nokia.com/doc/4.0/sql-driv...x-and-mac-os-x), these are the steps:
It also says:

You need the MySQL header files and as well as the shared library libmysqlclient.so. Depending on your Linux distribution you may need to install a package which is usually called "mysql-devel"
Now, I don't know much about Mac's (besides I can't afford one...), but you should use your package manager to download the package. Or maybe get it from the MySQL website?

lucasvickers
25th February 2010, 00:10
Hello,

I am having the exact same issue.

- I have triple checked and I only see one QT installer for OS X so I am not sure how one could download QT without the source.
- I have installed mysql and I have libmysqlclient.dylib , but there is no libmysqlclient.so . Does anyone know if working with a dynamic lib in QT is much different than a shared object?

TCB13
28th August 2011, 22:47
Hi,
Someone could really make a easy to use installer to make this plugin.

Anyway the close thing I got to that is: http://code.google.com/p/freemedforms/source/browse/trunk/scripts/mac-create-mysql-plugin.sh

That script aims to build and place the mysql plugin. ;)

Best regards.

unix7777
1st September 2011, 14:45
Aims != does :)

i wrote here many times and still got no answer or solution.
I try to compile and install MYSQL driver on Mac OS.I do the following:

1.Download MySQL for Mac OS
2.Download QT source code
3.cd /Users/myuser/Downloads/qt-everywhere-opensource-src-4.7.3/src/plugins/sqldrivers/mysql
4.set namespec:

export QMAKESPEC=/Users/myuser/Downloads/qt-everywhere-opensource-src-4.7.3/mkspecs/macx-g++

5.qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
6. make

7.Than i receive 94KB file libqsqlmysql.dylib
Comparing it with other drivers is too small.
I copy this file in the /plugin folder of installed QT

8.I create a new project and add to MyProject.pro QT += sql
Also #include <QtSql> to the main.cpp

9. i try this code



QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("172.16.10.103");
db.setDatabaseName("test");
db.setUserName("joro");
db.setPassword("test");
bool ok = db.open();


10. i got this error

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

pasomas
12th February 2012, 01:34
The thread is quite old but could be very useful for someone. :)
If you followed these steps http://doc.qt.nokia.com/4.0/sql-driver.html#how-to-build-the-plugin-on-unix-and-mac-os-x and had no errors/warnings,
using Qt sources and development package of MySQL , the size of the result lib it's ok (for the release one).
Point 7 : instead of a direct copy it's better a make install to be sure of the destination path.
Before the point 8 and after the install there's another step : you've to change the result lib with this cmd (you'll find it in the last rows of the script mentioned by TCB13) :

install_name_tool -change libmysqlclient.18.dylib $MYSQL_LIB/libmysqlclient.18.dylib $QT_PLUGIN_PATH/sqldrivers/libqsqlmysql.dylib

where
MYSQL_LIB=/usr/local/mysql/lib (normally the dft installation path for MySQL, again see the script)
and

QT_PLUGIN_PATH=`qmake -query QT_INSTALL_PLUGINS`.

MySQL client lib could change on the basis of MySQL api version (check the existent in the previous path).

After that everything'll work fine.:)