Results 1 to 10 of 10

Thread: Create a windows application with sqlite

  1. #1
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Create a windows application with sqlite

    Hi everyone, I'm new on Qt, so maybe my problem is not that big, but I've searched a bit and didn't found a solution yet.
    I've written an application using Qt under Linux environment, everything worked well. Then I've compiled it under xp and still everything worked well. Now I want to distribute it on computer that has not Qt installed, so I copied the exe compiled under xp, and with it I copied the dll needed (qtsql4, qtgui4, qtcore4, mingwm10) and when I run the application the "Unable to establish a database connection. This example needs SQLite support. Please read the Qt SQL driver documentation for information how to build it. Click Cancel to exit." message that is in a "connection.h" file that I show below. I really don't know how to go on...

    Qt Code:
    1. #include <QTimer>
    2. #include <QtSql>
    3. #include <QMessageBox>
    4.  
    5. static bool createConnection()
    6. {
    7. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    8. // db.setDatabaseName(":memory:");
    9. db.setDatabaseName("yorkshire_db");
    10. if (!db.open()) {
    11. QMessageBox::critical(0, qApp->tr("Cannot open database"),
    12. qApp->tr("Unable to establish a database connection.\n"
    13. "This example needs SQLite support. Please read "
    14. "the Qt SQL driver documentation for information how "
    15. "to build it.\n\n"
    16. "Click Cancel to exit."), QMessageBox::Cancel);
    17. return false;
    18. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create a windows application with sqlite

    to deploy an application that uses plugins you have to follow instructions in http://doc.trolltech.com/4.5/deployment.html.

    you must create a "sqldrivers" subdirectory in executable directory and copy the qsqlite drivers into.
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create a windows application with sqlite

    Thank you! I am now reading it... and try to plug things in...

  4. #4
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create a windows application with sqlite

    Ok, I created the /sqldrivers directory and copied sqldrivers inside... but still the same error...
    This is my application's directory tree:
    \myappdirectory
    - myapp.exe
    - qtcore4.dll
    - qtgui4.dll
    - qtsql4.dll
    - sqldrivers \

    - qsqlite4.dll
    - libqsqlite4.a

  5. #5
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create a windows application with sqlite

    you need to have sqlite3.dll in you path. If you don't, you can copy it in sqldrivers folder.

    I suggest you to use some tool to discover dependencies. See Dependency Walker
    A camel can go 14 days without drink,
    I can't!!!

  6. #6
    Join Date
    Nov 2008
    Posts
    142
    Thanks
    3
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Create a windows application with sqlite

    Also, you do not need libqsqlite4.a. This is a static library that would only be required at compile time if you wanted to statically link in Qt's SQLite support. But you do not need to deploy it.

  7. #7
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create a windows application with sqlite

    Thank you everybody...
    Well, I did use dependency walker and found out I was missing msjava.dll, fixed the problem, but it wasn't my problem... :P
    Still getting the message about sqlite, and dependency didn't show anything about sqlite...

    I do copied sqlite3.dll in sqldrivers directory... now I am wondering if there is a version problem with the dlls...
    And, by the way, I have to mention that I developed the application in linux, and compiled it in vista, and ported it to a xp enviroment... maybe there is something related to this too?
    And maybe I should write a different code to found out the specific problem and not a generic
    Qt Code:
    1. if (!db.open()) {
    To copy to clipboard, switch view to plain text mode 
    ?!? But in this case... I don't know what to write...

  8. #8
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Create a windows application with sqlite


  9. #9
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create a windows application with sqlite

    Well... before to start to track the error I just wanted to check if installing qt on the xp machine the app would work and... surprise! No.
    So I installed the windows version of QT SDK and compiled the source files and... f**k! Same problem! Seems that sqlite drivers are not installed either...
    Now I'm recompiling qt... but the question is: even without qt installed I need the application to work!

  10. #10
    Join Date
    Jun 2009
    Posts
    8
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink Re: Create a windows application with sqlite

    Just to say that everything now works correct. Just needed to delete all the non .h, .cpp, .pro file (clean up the directory...) and then compile.

    I compile in XP environment.

    On the deployment machine I had the directory with my exe, with mingwm10.dll (taken from mingw directory in qt installation directory) and qtcore4, qtsql4, qtgui4 dlls (taken from bin directory in qt installation directory), than a directory "sqldrivers" and there the qsqlite4.dll taken from qt/plugins/sqldrivers directory in the qt installation directory.

    Everytime I change something in my application I simply compile in the XP environment and then copy the exe file in the main directory.

    Happy, at the end.

  11. The following user says thank you to nittalope for this useful post:

    neuronet (14th November 2014)

Similar Threads

  1. transporting qt application fron linux to windows
    By deekayt in forum Qt Programming
    Replies: 4
    Last Post: 20th October 2006, 22:56
  2. How to create MDI windows using Qt4 designer?
    By miaoliang in forum Qt Tools
    Replies: 3
    Last Post: 19th October 2006, 08:50
  3. Porting Qt application on windows from linux
    By safknw in forum Qt Programming
    Replies: 13
    Last Post: 22nd May 2006, 13:11
  4. Replies: 10
    Last Post: 28th April 2006, 15:48
  5. Application plugin on windows
    By Eyee in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2006, 17:36

Tags for this Thread

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.