July 15, 2011

C0wboy111 C0wboy111
Lab Rat
4 posts

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.

12 replies

July 15, 2011

Eddy Eddy
Area 51 Engineer
1563 posts

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.

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

July 15, 2011

C0wboy111 C0wboy111
Lab Rat
4 posts

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…

July 15, 2011

Eddy Eddy
Area 51 Engineer
1563 posts

Did you update your ldconfig?

What version of ubuntu are you on?

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

July 15, 2011

C0wboy111 C0wboy111
Lab Rat
4 posts

I’m on ubuntu 10.10

What do I need to do with ldconfig?

July 15, 2011

Eddy Eddy
Area 51 Engineer
1563 posts

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

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

July 15, 2011

C0wboy111 C0wboy111
Lab Rat
4 posts

Yep, I had tried that. No dice.

July 15, 2011

Eddy Eddy
Area 51 Engineer
1563 posts

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

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

July 16, 2011

cincirin cincirin
Ant Farmer
444 posts

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

July 17, 2011

dialingo dialingo
Lab Rat
158 posts

No need to compile, rather do:

  1. apt-get install  libqt4-sql-mysql

July 17, 2011

saidiahd saidiahd
Lab Rat
36 posts

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 .

 Signature 

“Learn from yesterday, live for today, hope for tomorrow.” - Albert Einstein -

November 13, 2011

Flesh Flesh
Lab Rat
8 posts

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.

 Signature 

Jeff Flesher
http://VetsHelpCenter.com/

November 16, 2011

raja26 raja26
Lab Rat
76 posts

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 [techieshome.in]

 
  ‹‹ Does Qt4.7.3 have specific requirement of the glibc version?      Static Qt with static MSVC C++ library ››

You must log in to post a reply. Not a member yet? Register here!