Results 1 to 10 of 10

Thread: Can't find QPSQL driver!!

  1. #1
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Can't find QPSQL driver!!

    Guys I'm having problems, the program can't load the QPSQL driver:

    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers:

    How you can see, no drivers are available, but in the qt directory:

    brevleq@brevleq:/usr/local/Trolltech/Qt-4.3.0/plugins/sqldrivers$ ls

    libqsqlite.so libqsqlmysql.so libqsqlpsql.so
    libqsqlite.so.debug libqsqlmysql.so.debug libqsqlpsql.so.debug

    In Trolltech site they teaches how to build the driver, I did all they said but when I run ldd:

    ldd libqsqlpsql.so
    ldd: ./libqsqlpsql.so: No such file or directory

    how can I resolve it?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can't find QPSQL driver!!

    Could you post the output of "ls -al /usr/local/Trolltech/Qt-4.3.0/plugins/sqldrivers/" here? And additionally do you have mysql/postgresql client libraries installed?

  3. #3
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: Can't find QPSQL driver!!

    brevleq@brevleq:~$ ls -al /usr/local/Trolltech/Qt-4.3.0/plugins/sqldrivers/
    total 1773
    drwxr-xr-x 2 root root 224 2007-10-28 22:43 .
    drwxr-xr-x 9 root root 256 2007-10-28 18:12 ..
    -rwxr-xr-x 1 root root 345060 2007-10-28 18:12 libqsqlite.so
    -rw-r--r-- 1 root root 926708 2007-10-28 15:24 libqsqlite.so.debug
    -rwxr-xr-x 1 root root 56444 2007-10-28 18:12 libqsqlmysql.so
    -rw-r--r-- 1 root root 420993 2007-10-28 15:24 libqsqlmysql.so.debug
    -rwxr-xr-x 1 root root 56172 2007-10-28 22:43 libqsqlpsql.so

    I don't know if I have the client of postgre! I just instaled a pre-compiled package from linuxpackages.net, I can acess the database using PgAdmin3. What should I do to know if I have the client??

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't find QPSQL driver!!

    What does "ldd /usr/local/Trolltech/Qt-4.3.0/plugins/sqldrivers/libqsqlpsql.so" output?

  5. #5
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't find QPSQL driver!!

    brevleq@brevleq:~$ ldd /usr/local/Trolltech/Qt-4.3.0/plugins/sqldrivers/libqsqlpsql.so
    linux-gate.so.1 => (0xffffe000)
    libpq.so.5 => /usr/lib/libpq.so.5 (0xb7f54000)
    libQtSql.so.4 => /usr/local/Trolltech/Qt-4.3.0/lib/libQtSql.so.4 (0xb7f1c000)
    libQtCore.so.4 => /usr/local/Trolltech/Qt-4.3.0/lib/libQtCore.so.4 (0xb7d73000)
    libz.so.1 => /usr/lib/libz.so.1 (0xb7d5f000)
    libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb7d5a000)
    librt.so.1 => /lib/librt.so.1 (0xb7d52000)
    libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb7cbf000)
    libdl.so.2 => /lib/libdl.so.2 (0xb7cbb000)
    libpthread.so.0 => /lib/libpthread.so.0 (0xb7ca4000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7bc0000)
    libm.so.6 => /lib/libm.so.6 (0xb7b98000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0xb7b8d000)
    libc.so.6 => /lib/libc.so.6 (0xb7a4b000)
    libssl.so.0 => /usr/lib/libssl.so.0 (0xb7a0b000)
    libcrypto.so.0 => /usr/lib/libcrypto.so.0 (0xb78cd000)
    libcrypt.so.1 => /lib/libcrypt.so.1 (0xb789f000)
    /lib/ld-linux.so.2 (0x80000000)

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can't find QPSQL driver!!

    And what does "qmake -v" return?

  7. #7
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't find QPSQL driver!!

    qmake -v
    QMake version 2.01a
    Using Qt version 4.3.0 in /usr/local/Trolltech/Qt-4.3.0/lib

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't find QPSQL driver!!

    Everything seems to be OK with the installation. Do you create QCoreApplication or QApplication instance before you try to access the database?

  9. #9
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't find QPSQL driver!!

    I didn't create the QCoreApplication or QApplication in the class I'm using to manipulate database, but the main.cpp have this declaration like you can see:

    Qt Code:
    1. ------ManipulaDados.h--------
    2.  
    3. #ifndef MANIPULABANCO_H
    4. #define MANIPULABANCO_H
    5.  
    6. #include <QSqlError>
    7. #include <QMessageBox>
    8. #include <QSqlDatabase>
    9. #include <QSqlQuery>
    10.  
    11. class ManipulaBanco{
    12. public:
    13. ManipulaBanco(void);
    14. private:
    15. bool conecta(void);
    16. QSqlDatabase banco;
    17. };
    18.  
    19. #endif
    20.  
    21.  
    22.  
    23. -----------ManipulaBanco.cpp------------
    24.  
    25. #include "ManipulaBanco.h"
    26.  
    27. #include <iostream>
    28.  
    29. using namespace std;
    30.  
    31. ManipulaBanco::ManipulaBanco(){
    32. conecta();
    33. }
    34.  
    35. bool ManipulaBanco::conecta(void){
    36. banco=QSqlDatabase::addDatabase("QPSQL");
    37. banco.setHostName("localhost");
    38. banco.setDatabaseName("caixa Xpress");
    39. banco.setUserName("brevleq");
    40. banco.setPassword("hoask8");
    41. if(!banco.open()){
    42. cout<<"Não foi possÃ*vel conectar ao banco!!";
    43. //QMessageBox::critical(0,QObject::tr("Não foi possÃ*vel conectar ao servidor!!"),banco.lastError().text());
    44. return(false);
    45. }
    46. return(true);
    47. }
    48.  
    49.  
    50. ------------main.cpp-----------
    51.  
    52. #include <QApplication>
    53.  
    54. #include "ManipulaBanco.h"
    55. #include "TelaPrincipal.h"
    56.  
    57. int main(int argc,char *argv[]){
    58. ManipulaBanco aux;
    59. QApplication app(argc,argv);
    60. TelaPrincipal *dialog=new(TelaPrincipal);
    61. dialog->show();
    62. return app.exec();
    63. }
    To copy to clipboard, switch view to plain text mode 

    These are the principals (the plural is write like this??) source files for this question!!
    Last edited by jacek; 30th October 2007 at 00:30. Reason: missing [code] tags

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't find QPSQL driver!!

    Quote Originally Posted by brevleq View Post
    ...
    ManipulaBanco aux;
    QApplication app(argc,argv);
    ...
    You have to swap those two lines. QApplication must be created first, because it's responsible for loading all of the plugins and other Qt initialization stuff.
    Last edited by jacek; 30th October 2007 at 00:35. Reason: typo

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

    canislupax (29th November 2010)

Similar Threads

  1. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15

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.