PDA

View Full Version : MySQL driver on Mac OS X



Vit_H
18th March 2011, 22:54
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?

schnitzel
19th March 2011, 19:55
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:


c:/mysql
include/...
lib/...

unix7777
20th March 2011, 21:56
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?

Vit_H
21st March 2011, 10:16
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:


c:/mysql
include/...
lib/...

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:

libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
/usr/local/Trolltech/Qt-4.7.2/lib/QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.2)
/usr/local/Trolltech/Qt-4.7.2/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.2)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 830.0.0)



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:

INCLUDEPATH += /usr/local/mysql/include
LIBS += -L/usr/local/mysql/lib -lmysqlclient_r

unix7777
21st March 2011, 22:26
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