PDA

View Full Version : QSqlDatabase: QMYSQL driver not loaded



edsonmcz
16th October 2011, 17:19
I use Mac OS X, I did download of QT, have been installed.

But when I use QT Creator for compile my applications and tried connect in MYSQL this error happened :



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


I thanks who can help me !

inbush
16th October 2011, 17:40
see here http://www.qtcentre.org/threads/45295-using-mysql-plugin

edsonmcz
16th October 2011, 19:47
I don't unsdertand, I try this :

"INCLUDEPATH = /usr/local/mysql-5.5.9-osx10.6-x86_64/include" "LIBS =- L / usr/local/mysql-5.5.9-osx10.6-x86_64/lib-lmysqlclient_r"mysql.pro

I haven't folder mysql-5.5.9-osx10.6-x86_64.

But this way don't exist in my path.

Thanks for help me.

For MacOs X
Download and install QTSDK. After this, go to the configuration utility and install additional islhodnye codes.
Download and affix the software package MySQL (for example a mysql-5.1.53-osx10.6-x86_64.dmg, although the service I did not start.)
Next, look for a folder with qmake (/ Users/inbush/QtSDK/Desktop/Qt/471/gcc/bin/qmake)
Folder with the source MySQL (/ usr/local/mysql-5.1.53-osx10.6-x86_64/include)
Open a terminal and go to the folder plugin (Creativus: ~ inbush $ cd / Users/inbush/QtSDK/QtSources/4.7.1/src/plugins/sqldrivers/mysql)
Putting the project / Users/inbush/QtSDK/Desktop/Qt/471/gcc/bin/qmake-o Makefile "INCLUDEPATH = / usr/local/mysql-5.1.53-osx10.6-x86_64/include" "LIBS =- L / usr/local/mysql-5.1.53-osx10.6-x86_64/lib-lmysqlclient_r "mysql.pro
make
make install

Added after 34 minutes:

I tried this too :


macbookpro$ ./qmake -o Makefile "INCLUDEPATH+=/Users/macbookpro/mysql-5.5.9-osx10.6-x86_64/include" "LIBS+=-L/Users/macbookpro/mysql-5.5.9-osx10.6-x86_64/lib-lmysqlclient_r" mysql.pro
Cannot find file: mysql.pro.
:bin macbookpro$

inbush
16th October 2011, 21:17
No, you are wrong. Lets try from the verybeginning, step by step. I'm using Mac OS too.
1. Download and install QTSDK. After this, go to the configuration SDK utility and install additional source codes for the version of Qt you use.
2. Download and install the software package MySQL (for example a mysql-5.1.53-osx10.6-x86_64.dmg) (I couldn't compile drivers for 5.5 version. in the previous post has version mistake, my fault)
3. Next, look for a folder with qmake (/ Users/inbush/QtSDK/Desktop/Qt/471/gcc/bin/qmake) (or the version you use, now it is 474)
4. Folder with the source MySQL (/usr/local/mysql-5.1.53-osx10.6-x86_64/include) (if you user another version change the version numbers of mysql) (shift+command+G - the folder is hidden)
5. Open a terminal and go to the folder plugin (Creativus: ~ inbush $ cd / Users/inbush/QtSDK/QtSources/4.7.4/src/plugins/sqldrivers/mysql) (remember about the version, <inbush> - user)
6. In terminal execute
/Users/<username>/QtSDK/Desktop/Qt/474/gcc/bin/qmake-o Makefile "INCLUDEPATH = /usr/local/mysql-5.1.53-osx10.6-x86_64/include" "LIBS =- L /usr/local/mysql-5.1.53-osx10.6-x86_64/lib-lmysqlclient_r "mysql.pro

this will execute qmake
7. in terminal make
8. in terminal make install

thats all. Woks on snow leo and lion x64 with 471-474 Qt and 5.1.x MySQL

If you get any mistakes post them here i'll try to help you.

edsonmcz
16th October 2011, 23:01
Thanks a lot

I think that I did all, but now this error is happened




MacBook-Pro:mysql macbookpro$ /Users/macbookpro/QtSDK/Simulator/Qt/gcc/bin/qmake Makefile "INCLUDEPATH = /usr/local/mysql-5.5.9-osx10.6-x86_64/include" "LIBS =- L /usr/local/mysql-5.5.9-osx10.6-x86_64/lib-lmysqlclient_r "mysql.pro
Cannot find file: Makefile.
MacBook-Pro:mysql macbookpro$


I don't know what is this error, thanks for help me !

Added after 26 minutes:

This error happened:



MacBook-Pro:mysql macbookpro$ /Users/macbookpro/QtSDK/Simulator/Qt/gcc/bin/qmake -o Makefile "INCLUDEPATH = /usr/local/mysql-5.5.9-osx10.6-x86_64/include" "LIBS = -L /usr/local/mysql-5.5.9-osx10.6-x86_64/lib -lmysqlclient_r " mysql.pro
MacBook-Pro-de-MacBook-Pro:mysql macbookpro$ make
make -f Makefile.Debug all
rm -f libqsqlmysql_debug.dylib
g++ -headerpad_max_install_names -arch x86_64 -single_module -dynamiclib -Xarch_x86_64 -mmacosx-version-min=10.5 -Xarch_x86_64 -mmacosx-version-min=10.5 -o libqsqlmysql_debug.dylib .obj/debug-shared/main.o .obj/debug-shared/qsql_mysql.o .obj/debug-shared/moc_qsql_mysql.o -F/Users/macbookpro/lib -L/Users/macbookpro/lib -L /usr/local/mysql-5.5.9-osx10.6-x86_64/lib -lmysqlclient_r -framework QtSql -L/Users/macbookpro/lib -F/Users/macbookpro/lib -framework QtCore
ld: -L must be immediately followed by a directory path (no space)
collect2: ld returned 1 exit status
make[1]: *** [../../../../../../../plugins/sqldrivers/libqsqlmysql_debug.dylib] Error 1
make: *** [debug-all] Error 2
MacBook-Pro:mysql macbookpro$


Added after 15 minutes:

I tried this form too :



MacBook-Pro:mysql macbookpro$ /Users/macbookpro/QtSDK/Simulator/Qt/gcc/bin/qmake -o Makefile "INCLUDEPATH = /usr/local/mysql-5.5.9-osx10.6-x86_64/include" "LIBS =- L /usr/local/mysql-5.5.9-osx10.6-x86_64/lib -lmysqlclient_r " mysql.pro
MacBook-Pro:mysql macbookpro$ makemake -f Makefile.Debug allrm -f libqsqlmysql_debug.dylibg++ -headerpad_max_install_names -arch x86_64 -single_module -dynamiclib -Xarch_x86_64 -mmacosx-version-min=10.5 -Xarch_x86_64 -mmacosx-version-min=10.5 -o libqsqlmysql_debug.dylib .obj/debug-shared/main.o .obj/debug-shared/qsql_mysql.o .obj/debug-shared/moc_qsql_mysql.o -F/Users/macbookpro/lib -L/Users/macbookpro/lib - L /usr/local/mysql-5.5.9-osx10.6-x86_64/lib -lmysqlclient_r -framework QtSql -L/Users/macbookpro/lib -F/Users/macbookpro/lib -framework QtCore
i686-apple-darwin10-g++-4.2.1: L: No such file or directory
i686-apple-darwin10-g++-4.2.1: -E or -x required when input is from standard input
make[1]: *** [../../../../../../../plugins/sqldrivers/libqsqlmysql_debug.dylib] Error 1
make: *** [debug-all] Error 2


Thanks a lot

inbush
16th October 2011, 23:46
In my opinion you should try to compile with /QtSDK/Desktop/Qt/474/gcc qmake directory.

Also several months ago i tryed to compile mysql5.5x drivers too, and failed. So I removed MySQL 5.5 and installed 5.1.x Mysql ver. Everything compiled from the first time. But i Got a problem with removing MySQL. After removing the installation of the earlier version was impossible. Short instruction how to solve this problem, if you need.

sudo rm /usr/local/mysql
sudo rm rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*

Also do the following and you will be able to completely remove MySQL 5.5 from Mac OS 10 Snow Leopard.

sudo rm -rf /private/var/db/receipts/com.mysql.mysql*

after this install 5.1 version with libraries and recompile drvs from the beginning.

After i installed 5.1 version and compiled drivers, I use them with 5.5 versions (installed on other server) for a long time with mo errors and good stability.

edsonmcz
17th October 2011, 17:40
Before, thanks a lot.

Sorry, I have many applications run in MySql, then I tried use Sqlite.

Was work very good.

oliverliu.hz
15th November 2014, 07:29
1. download mysql from mysql official website, notice correspond with your system
2. setup it
3. qmake mysql plugin in Qt plugin folder with source code
4. make install in source code folder
5. use it.
Notice: check mysql dynamic library in library path after you install mysql package.