[Qt-interest] loading sql plug in
Robert Escott
robert at binarylogic.co.za
Tue Sep 29 20:18:31 CEST 2009
I don't understand why you're creating macros inside your project.
I had problems initially when I wanted to use MySQL as well. There are a few things you should do before you can successfully connect to the database:
1) Qt doesn't come with the plugin already made, it only has the wrapper code needed to create the plugin. The project for this is found in <QTDIR>\src\plugins\sqldrivers\mysql. The instructions for creating the plugin can be read at http://doc.trolltech.com/4.5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows and will result in a file called qsqlmysql.dll being created and placed in <QTDIR>\plugins\sqldrivers.
2) The plugin itself is only an adapter between the QtSql module and the actual MySQL library. To use the plugin, you need to copy the MySQL library to your <QTDIR>\bin directory. The file you're looking for is libmysql.dll and can be found in your <MYSQL>\lib\opt directory.
3) If you wish to deploy your program to another computer where these libraries are not installed, you need to place them in the following paths:
<APPDIR>\libmysql.dll
<APPDIR>\sqldrivers\qsqlmysql.dll
Once you've done the above, you don't even have to think about loading and unloading the plugin from your code, you just go right ahead.
#include <QSqlDatabase>
int main(int argc, char **argv){
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("Addu");
db.setHoseName("localhost");
db.setPort(-1);
db.setUserName("root");
db.setPassword("");
if (!db.open())
return -1;
return 0;
}
That's all. You don't even have to think about the plugin in your code.
I hope this solves your problem.
Robert
----- Original Message -----
From: Yuvaraj R
To: qt-interest at trolltech.com
Cc: Thiago Macieira
Sent: Tuesday, September 29, 2009 1:27 PM
Subject: Re: [Qt-interest] loading sql plug in
I resolved the my previous error...
Now i am facing new error,
error is
qt_plugin_instance_qsqlmysql()
what's is there previous mentioned code
please help me
Thanks
Yuvaraj R
On Tue, Sep 29, 2009 at 1:22 PM, Yuvaraj R <yuvaraj at ongobiz.com> wrote:
Hi All place the Sql folder outside of project..It contains following files
1) qsqlmysql
2)libqsqlmysql4.a
My .pro file is
TARGET = MaxxTel
TEMPLATE = app
QT += core \
gui \
xml \
network
QT += sql
QTPLUGIN += qsqlmysql
SOURCES += main.cpp \
mainwindow.cpp \
widget1.cpp \
pjcallback.cpp \
buddy.cpp \
form.cpp \
setting_form.cpp \
treewidget_override.cpp \
registration_form.cpp \
conference.cpp \
tab_widget.cpp \
window_alert.cpp \
text_edit1.cpp \
style_sheet.cpp \
line_edit.cpp \
string_new.cpp \
login.cpp \
create_database.cpp \
history_call.cpp
HEADERS += mainwindow.h \
widget1.h \
pjcallback.h \
buddy.h \
form.h \
setting_form.h \
treewidget_override.h \
registration_form.h \
conference.h \
tab_widget.h \
window_alert.h \
text_edit1.h \
style_sheet.h \
line_edit.h \
string_new.h \
login.h \
create_database.h \
../connection.h \
history_call.h
FORMS += mainwindow.ui \
widget1.ui \
form.ui \
setting_form.ui \
registration_form.ui \
window_alert.ui \
login.ui \
conference.ui
INCLUDEPATH += ../pjproject-1.0.2/pjlib/include \
../pjproject-1.0.2/pjlib-util/include \
../pjproject-1.0.2/pjnath/include \
../pjproject-1.0.2/pjmedia/include \
../pjproject-1.0.2/pjsip/include
LIBS += -L../pjproject-1.0.2/pjlib/lib \
-L../pjproject-1.0.2/pjlib-util/lib \
-L../pjproject-1.0.2/pjnath/lib \
-L../pjproject-1.0.2/pjmedia/lib \
-L../pjproject-1.0.2/pjsip/lib \
-L../pjproject-1.0.2/third_party/lib \
-L../Sql
RESOURCES += image.qrc
win32-g++:LIBS += -L../openssl-0.9.8g
win32-g++:LIBS += -lpjsua-i686-pc-mingw32 \
-lpjsip-ua-i686-pc-mingw32 \
-lpjsip-simple-i686-pc-mingw32 \
-lpjsip-i686-pc-mingw32 \
-lpjmedia-codec-i686-pc-mingw32 \
-lpjmedia-i686-pc-mingw32 \
-lpjnath-i686-pc-mingw32 \
-lpjlib-util-i686-pc-mingw32 \
-lpj-i686-pc-mingw32 \
-lportaudio-i686-pc-mingw32 \
-lgsmcodec-i686-pc-mingw32 \
-lilbccodec-i686-pc-mingw32 \
-lspeex-i686-pc-mingw32 \
-lresample-i686-pc-mingw32 \
-lmilenage-i686-pc-mingw32 \
-lsrtp-i686-pc-mingw32 \
-lm \
-lwinmm \
-lole32 \
-lws2_32 \
-lwsock32 \
-lqsqlmysql
when i am trying to build ,i am getting following error
cannot find -lqsqlmysql
Please help me to load the mysql plug in to my project
Thanks
Yuvaraj R
On Tue, Sep 29, 2009 at 11:17 AM, Yuvaraj R <yuvaraj at ongobiz.com> wrote:
Thanks for your reply
I realized my mistake..
still i didn't load the plug in
i place sql folder in my project and inserted the created qsqlmysql.dll in folder..
in pro file
LIBS += -L../sql
In my main function i used following macro
Q_IMPORT_PLUGIN(qsqlmysql)but i am getting following error.
error: undefined reference to `qt_plugin_instance_qsqlmysql()'
Thanks
Yuvaraj R
Then i added in my pro file ..
On Tue, Sep 29, 2009 at 11:07 AM, Christopher Rasch-Olsen Raa <christopher at technophile.info> wrote:
Hi,
What does the plugin-system say? Does your plugin get loaded? If so, what does
the errors you get when loading a database say? Without this information is
_really_ hard for us to help.
--
Christopher
On Tuesday 29 September 2009 07:31:14 Yuvaraj R wrote:
> Hi All
>
> I created the sql plug in .
>
> I tried with
>
>
> QSqlDatabase db = QSqlDatabase::addDatabase("Mysql");
>
> db.setDatabaseName("Addu");
>
> but i am getting error..
>
> how do i use the plugin in my project and upload to project.
>
> please help me
>
> can anybody provide me a useful links
>
> Thanks
>
> Yuvaraj R
>
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090929/2b8f9e30/attachment.html
More information about the Qt-interest-old
mailing list