Results 1 to 12 of 12

Thread: QtService & QtSql

  1. #1

    Default QtService & QtSql

    Hi all~ I've make a small service by qtservice, the service will query database by QSqlDatabse with MySql plugin.

    on my developement platform, all thing work fine.
    on a clean system which we will distributed our app to, the service itself work fine, but the QSqlDatabase object will be invalid while call "addDatabase", which usually means DB driver not found. i've already copy all qt dll and plugins to the same path with execute file, I also try to put them in system32, still not working~

    it only happen if QSqlDatabase object is used in a qtservice application. it is working correctly while used in a general application.

    so my problem is: how qtservice manage its plugin path? how to install plugin path correctly while we distribute developed qtservice application?

    any answer would be appreciate~~
    thx~~~

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtService & QtSql

    I think the problem is missing MySQL DLL's. Use DependencyWalker on this "clean" machine and You will see what is missing.

    P.S.
    I see that in "normal" mode all is working

  3. #3

    Default Re: QtService & QtSql

    really thx for reply~

    I understand the scenario is qtsql did not find qsqlmysql4.dll plugin.

    my confussion is: Why? i've already put this plugin in the same path as execution file. and also in "C:\QT\4.6.2-vc\qt\plugins\sqldrivers" which is same as my developement pc.

    Why the plugin would be found if the execution file using qtsql is build as a normal application but not a "qtservice " application?

    P.S. the service application is launch by qtservicecontroller or system service control panel (after service installed) but NOT directly execute.

  4. #4
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QtService & QtSql

    One year later, was any solution found for this problem?

    I'm facing the same issue with QtService and QMYSQL. My service only reports to have found these plugins: "QSQLITE, QODBC3, QODBC'", but I need QMYSQL, which is right in my sqlplugins directory.

  5. #5
    Join Date
    Nov 2011
    Posts
    9
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QtService & QtSql

    I have the same problem but on the static version of Qt. If you have the default version of QT you must compile MYSQL driver using the libraryes provided by the mysql site. When you deploy the app you must make another directory where the exe is, named "sqldrivers" and copy qslmysql.dll there.


    Here is a link that helped me to build it for the dynamic version of qt.
    http://doc.qt.nokia.com/stable/sql-driver.html

  6. #6
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QtService & QtSql

    That's not exactly the problem here: our programs work flawlessly when executed as standalone applications. I use the default version of Qt, I've compiled the MySQL driver as that website says, and everything runs fine on a regular Qt4 application.

    The problem is trying to run a QtService with the MySQL plugin, as the service won't find the plugin. A possible solution would be to recompile Qt4 with -qt-sql-driver, but that'd be really time consuming and I was looking for a quicker solution.

  7. #7
    Join Date
    Nov 2011
    Posts
    9
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QtService & QtSql

    Do you deploy the service in Windows or in unix ?
    If you manage to compile using -qt-sql-mysql please tell me how It seems that I cannot manage to compile using nmake...

  8. #8
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QtService & QtSql

    I'm working on Windows right now, but with mingw, not with msvc. I once managed to compile with -qt-sql-mysql, but I was cross-compiling on Linux for QtEmbedded.

  9. #9
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QtService & QtSql

    Hm, actually, it works like a charm in release, it only fails on debug, so there must be something fishy with my debug libraries...

  10. #10
    Join Date
    Nov 2011
    Posts
    9
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QtService & QtSql

    Probably you already know that on debug it searches for qsqlmysql4.dll with d in the name: qsqlmysqld4.dll or something.

  11. #11
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QtService & QtSql

    Indeed, but for some reason it won't find my sqldrivers/qsqlmysqld4.dll, go figure...

  12. #12
    Join Date
    Oct 2014
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtService & QtSql

    Try this, it works for me.


    int main(int argc, char *argv[])
    {
    QString app_path = QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath();
    QCoreApplication::addLibraryPath(app_path);

    OpcService service(argc, argv);
    return service.exec();
    }


    And copy qsqlmysql4.dll to "sqldrivers" subdirectory of your .exe file.

Similar Threads

  1. QtService Library (dll) for windows
    By ruben.rodrigues in forum Installation and Deployment
    Replies: 1
    Last Post: 22nd October 2010, 19:18
  2. QtService on Windows as Non-Interactive
    By stefanadelbert in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2010, 03:27
  3. Help on QTcpSocket, QTService and QThread
    By josecarlosmissias in forum Newbie
    Replies: 1
    Last Post: 12th November 2009, 16:37
  4. QtService fails to start
    By a550ee in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2006, 13:34
  5. QtService and GAC loadable dll
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 17th July 2006, 03:39

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.