PDA

View Full Version : Can't find QPSQL driver!!



brevleq
28th October 2007, 23:14
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?

wysota
29th October 2007, 08:38
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?

brevleq
29th October 2007, 12:33
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??

jacek
29th October 2007, 12:36
What does "ldd /usr/local/Trolltech/Qt-4.3.0/plugins/sqldrivers/libqsqlpsql.so" output?

brevleq
29th October 2007, 13:42
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)

wysota
29th October 2007, 18:45
And what does "qmake -v" return?

brevleq
29th October 2007, 22:57
qmake -v
QMake version 2.01a
Using Qt version 4.3.0 in /usr/local/Trolltech/Qt-4.3.0/lib

jacek
29th October 2007, 23:27
Everything seems to be OK with the installation. Do you create QCoreApplication or QApplication instance before you try to access the database?

brevleq
30th October 2007, 00:25
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:



------ManipulaDados.h--------

#ifndef MANIPULABANCO_H
#define MANIPULABANCO_H

#include <QSqlError>
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlQuery>

class ManipulaBanco{
public:
ManipulaBanco(void);
private:
bool conecta(void);
QSqlDatabase banco;
};

#endif



-----------ManipulaBanco.cpp------------

#include "ManipulaBanco.h"

#include <iostream>

using namespace std;

ManipulaBanco::ManipulaBanco(){
conecta();
}

bool ManipulaBanco::conecta(void){
banco=QSqlDatabase::addDatabase("QPSQL");
banco.setHostName("localhost");
banco.setDatabaseName("caixa Xpress");
banco.setUserName("brevleq");
banco.setPassword("hoask8");
if(!banco.open()){
cout<<"Não foi possÃ*vel conectar ao banco!!";
//QMessageBox::critical(0,QObject::tr("Não foi possÃ*vel conectar ao servidor!!"),banco.lastError().text());
return(false);
}
return(true);
}


------------main.cpp-----------

#include <QApplication>

#include "ManipulaBanco.h"
#include "TelaPrincipal.h"

int main(int argc,char *argv[]){
ManipulaBanco aux;
QApplication app(argc,argv);
TelaPrincipal *dialog=new(TelaPrincipal);
dialog->show();
return app.exec();
}

These are the principals (the plural is write like this??) source files for this question!!

jacek
30th October 2007, 00:29
...
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.