Results 1 to 8 of 8

Thread: QMYSQL loading problem

  1. #1
    Join Date
    May 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QMYSQL loading problem

    Hi,

    I have built and compiled an application using VC++ 2005 and the QMYSQL plugin and it works on my development machine just fine. However, when I move the application (debug version) to a computer that has the MySQL server running on it, the QMYSQL driver won't load. Does anyone have any ideas? thanks.

    Daniel

  2. #2
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QMYSQL loading problem

    I have this problem too:

    my code:
    #include <QApplication>
    #include <QtGui>
    #include <QtSql>

    int main(int argc,char *argv[])
    {
    QApplication qapp(argc,argv);
    QTextEdit display;
    display.resize(400, 160);
    display.show();

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("mysql");
    db.setUserName("root");
    db.setPassword("111111");
    bool ok = db.open();

    return qapp.exec();
    }


    my error info:
    1>------ Build started: Project: MsnGeter, Configuration: Debug Win32 ------
    1>Performing Makefile project actions
    1>Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1> cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/include/QtCore" -I"C:/Qt/4.2.2/include/QtGui" -I"C:/Qt/4.2.2/include/QtGui" -I"C:/Qt/4.2.2/include" -I"." -I"C:/Qt/4.2.2/include/ActiveQt" -I"debug" -I"." -I"c:\Qt\4.2.2\mkspecs\win32-msvc2005" -Fodebug\ @C:\DOCUME~1\Liu\LOCALS~1\Temp\nmA0.tmp
    1>main.cpp
    1>.\main.cpp(17) : warning C4189: 'ok' : local variable is initialized but not referenced
    1> link /LIBPATH:"c:\Qt\4.2.2\lib" /NOLOGO /DEBUG /DEBUG /MANIFESTFILE:"debug\MsnGeter.intermediate.manifest " /SUBSYSTEM:WINDOWS /OUT:debug\MsnGeter.exe @C:\DOCUME~1\Liu\LOCALS~1\Temp\nmA1.tmp
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QSqlDatabase::~QSqlDatabase(void)" (__imp_??1QSqlDatabase@@QAE@XZ) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QSqlDatabase:pen(void)" (__imp_?open@QSqlDatabase@@QAE_NXZ) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QSqlDatabase::setPassword(class QString const &)" (__imp_?setPassword@QSqlDatabase@@QAEXABVQString@@ @Z) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QSqlDatabase::setUserName(class QString const &)" (__imp_?setUserName@QSqlDatabase@@QAEXABVQString@@ @Z) referenced in function _main
    1>NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 8\VC\bin\link.EXE"' : return code '0x460'
    1>Stop.
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QSqlDatabase::setDatabaseName(class QString const &)" (__imp_?setDatabaseName@QSqlDatabase@@QAEXABVQStri ng@@@Z) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QSqlDatabase::setHostName(class QString const &)" (__imp_?setHostName@QSqlDatabase@@QAEXABVQString@@ @Z) referenced in function _main
    1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QSqlDatabase __cdecl QSqlDatabase::addDatabase(class QString const &,class QString const &)" (__imp_?addDatabase@QSqlDatabase@@SA?AV1@ABVQStrin g@@0@Z) referenced in function _main
    1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static char * QSqlDatabase::defaultConnection" (__imp_?defaultConnection@QSqlDatabase@@2PADA)
    1>debug\MsnGeter.exe : fatal error LNK1120: 8 unresolved externals
    1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
    1>Build log was saved at "file://c:\Documents and Settings\Liu\My Documents\Visual Studio 2005\Projects\MsnGeter\MsnGeter\Debug\BuildLog.htm "
    1>MsnGeter - 11 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QMYSQL loading problem

    fengtian.we, add:
    QT += sql
    to .pro file.

    Only QtCore and QtGui modules are enabled by default. Other modules, like QtSql must be explicitly taken into use like mentioned above (and in the docs, of course).
    J-P Nurmi

  4. #4
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QMYSQL loading problem

    ################################################## ####################
    # Automatically generated by qmake (2.01a) ??? ?? 20 18:50:56 2007
    ################################################## ####################

    TEMPLATE = app
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .
    QT += sql //I add it here,is ok??

    # Input
    SOURCES += main.cpp

  5. #5
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QMYSQL loading problem

    Thank you Sir!!!! I 'm connect to mysql ok.

    but:
    at the VS2005,need to set the "Build Command Line",
    I think i shoud set it is:

    qmake -project //if file count or name chanaged,than shoud update the .pro file isn't
    qmake
    nmake /f Makefile.Debug

    So I think can't use the VS2005's Debug function.I will use the command line(nmake)

    (excuse for my Chinese English )

  6. #6
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QMYSQL loading problem

    Can I use the Sql Module without chanage .pro file?

    My Case:

    I use the MSVS 2005,QT 4.2.2

    I set the "Project Property"->"Configuration Properties"->"NMAKE":

    Build Command:
    qmake -project //because the file count or file name maybe chanag.
    qmake
    nmake /f Makefile.Debug

    but I want use the sql module........//this shoud add "QT += sql " to .pro file.

    so ........... Can I use the Sql Module without chanage .pro file?

  7. #7
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMYSQL loading problem

    Quote Originally Posted by fengtian.we View Post
    Can I use the Sql Module without chanage .pro file?
    so ........... Can I use the Sql Module without chanage .pro file?
    Before you connect on any sql device .. you can check:

    Qt Code:
    1. QStringList drivers = QSqlDatabase::drivers();
    2. std::cout << "### Your sql driver on bord are: " << qPrintable(drivers.join(" ")) << std::endl;
    3. if (!drivers.contains("QMYSQL")) {
    4. std::cout << "### Load QMYSQL Driver Fail!." << std::endl;
    5. return;
    6. }
    To copy to clipboard, switch view to plain text mode 

    If the driver is load , you can use it.... if drivers.size() are 0 no driver sql on board .. so simple..

  8. #8
    Join Date
    Feb 2007
    Posts
    71
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QMYSQL loading problem

    Thank you Patrik08~

    I konw now~

Similar Threads

  1. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  2. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  3. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  5. QSA: loading scripts at runtime
    By seneca in forum Qt Programming
    Replies: 0
    Last Post: 15th February 2006, 15:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.