Mysql for Qt on ubuntu



  • Can someone please explain how to build mysql into qt? The 4.7.4 help says to qmake mysql.pro, but I don't have this file after an offline install of the sdk. It doesn't exist.


  • Moderators

    Welcome to the forum!

    There has been a similar post here :
    http://developer.qt.nokia.com/forums/viewthread/1121

    Also when you click on the tag on the right of your post you will find all information concerning mysql including wiki pages.



  • The problem that I have been having is that after building the libqsqlmysql.so file, I still can't get Qt to recognize that the MYSQL driver is available. I have added LIBS += -lqsqlmysql to my project's .pro file, as well as a LIBS += -L/.... to point to where the .so file is located. The project links correctly, but gets a runtime error saying that SQLITE is the only available database.

    I have mysql client, server, and dev files installed, and I built the qt mysql driver using these. Is there some location that the driver must be placed in order for Qt to find it. Or perhaps I didn't build it correctly with the ./configure command. Should it be "static"? Should I build both the lib and the plugin?

    I've read just about every thread on qt with mysql that's in the forum and none of the solutions have worked yet...


  • Moderators

    Did you update your ldconfig?

    What version of ubuntu are you on?



  • I'm on ubuntu 10.10

    What do I need to do with ldconfig?


  • Moderators

    I was wrong about the ldconfig, sorry.

    Try this :

    Copy MySQL plugin to your Qt’s plugins directory,
    cp libqsqlmysql.so YourQtSdkPath/qt/plugins/sqldrivers



  • Yep, I had tried that. No dice.


  • Moderators

    One sure thing you can do is get the sources and compile using the mysql configure option.



  • Also you will need to copy libmysql(client).so to "YourQtSdkPath/qt/bin"



  • No need to compile, rather do:

    @apt-get install libqt4-sql-mysql@



  • first of all , you must check if your mySQL DB work correctly and you have the privilege to work with it. ( you must be the admin of your linux session and mySQL .



  • Did you ever get it to work?

    I having it working with Ubuntu Studio 11.04 installed from the Repos, version 4.7.2; but never did get it to work from the SDK; the plugin is copied into the plugin folder; I know that MySQL is working; it works find in the installed version; just not the SDK version.

    I tried compiling; but didn't see that it created creator; I know that is a separate issue; but it keep me from testing it; but I did copy the plugin which it created; still with no help.



  • Hi, I was also having the same problem. But I figured it out with some easy steps. You can actually install the qt-mysql library from Ubuntu's Synaptic Package manager. and move it to the folder where you Qt program is looking for libraries.

    I've written in my blog about it, if you have any doubt you can refer the following link "Qt MySQL Driver for Linux ":http://www.techieshome.in/2011/09/install-qt-mysql-driver-for-linux.html



  • [quote author="C0wboy111" date="1310700685"]Can someone please explain how to build mysql into qt? The 4.7.4 help says to qmake mysql.pro, but I don't have this file after an offline install of the sdk. It doesn't exist.[/quote]

    the sdk. It doesn't exist.[/quote]

    My friend try go in Qt Tools>Options>QtVersions>In Autodetected chose you Qt compiler>Look down click on Qt version 5 Details. Now look you PLUGINS folder and go. In sqldrivers folder check file libqsqlmysql.so exist and ins not protected.
    If u not have this file download form Ubuntu software center searching libqt5 for QT5 or liqt4 for QT4 and install later copy the installed file /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers for 64bits machine or /usr/lib/i386-linux-gnu/qt5/plugins/sqldrivers for 32bits machine. to you plugins proyect folder
    Sorry for my english regars from Argentina


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.