Results 1 to 3 of 3

Thread: How to load PSQL Driver for QT in Ubuntu

  1. #1
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question How to load PSQL Driver for QT in Ubuntu

    Hi ,

    Please help me in loading the psql driver for QT in my Ubuntu 8.04.1 system.
    Here Postgres 8.3.5 is also installed.


    I had installed the QT using following commands

    configure -static -nomake demos -nomake examples -nomake tools -qt-sql-psql

    ( As it is static , i guess no plugin option is needed )

    make
    sudo make install

    Installation is done.

    libqsqlpsql.a is created at the path /usr/local/Troll tech/Qt-4.5.1/plugins/sqldrivers

    I had added the path to LIBS in makefile
    i.e LIBS = -L/usr/local/Trolltech/Qt-4.5.1/plugins/sqldrivers

    I had written the following code
    #include<QtSql/QtSql>
    #include <QtSql/QSqlDatabase>

    qDebug() << "Sql Driver" << QSqlDatabase::drivers();
    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("localhost");
    db.setDatabaseName("template1");
    db.setUserName("postgres");
    qDebug() << db.lastError();


    After execution , i am getting the below error.


    Sql Driver ()
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers:
    QSqlError(-1, "Driver not loaded", "Driver not loaded")


    It means Still Driver is not loaded.

    Please mention what is missing or wrong here..

    EAGERLY AWAITING THE RESPONSE.

  2. #2
    Join Date
    Aug 2009
    Location
    Greece
    Posts
    69
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to load PSQL Driver for QT in Ubuntu

    From Qt docs "If you build the static version of Qt, static plugins is the only option for including Qt's predefined plugins." see the details in
    http://doc.qt.nokia.com/4.7/plugins-...static-plugins

  3. #3
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to load PSQL Driver for QT in Ubuntu

    Hi Rhayader,

    Thanks for suggesting the doc . As per the doc i included the following lines in the source file
    #include <QtSql/QSqlDriverPlugin>
    #include<QtCore/QtPlugin>
    #define QT_STATICPLUGIN 1
    Q_IMPORT_PLUGIN(qsqlpsql)

    I am not using QMAKe and .pro file , instead i am using make file .
    So i added
    LIBS += -L/$QTDIR/plugins/sqldrivers/ -lqsqlpsql
    I had also added
    QT += sql
    QTPLUGIN += qsqlpsql

    in the Makefile.

    Then when i compile i am getting below error
    /opt/DEVROOT//obj/home/srinivasareddy.b/SqlWorks/DBForm/main.o: In function `StaticqsqlpsqlPluginInstance':
    /home/srinivasareddy.b/SqlWorks/DBForm/myDBForm.h:9: undefined reference to `qt_plugin_instance_qsqlpsql()'
    collect2: ld returned 1 exit status
    make: *** [/opt/DEVROOT//bin/prd] Error 1

    Please suggest , if anymore changes are needed.
    I hope u moved me near to the solution .

    AWAITING YOUR RESPONSE.

Similar Threads

  1. install mysql driver for qt in ubuntu
    By doforumda in forum Qt Programming
    Replies: 3
    Last Post: 5th October 2010, 08:21
  2. SQL driver load problem
    By vieraci in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2009, 14:59
  3. Cannot load SQL driver in Visual C++ (but works in QtCreator)
    By Tomis in forum Installation and Deployment
    Replies: 2
    Last Post: 5th November 2009, 15:32
  4. psql driver and s60
    By [maTa] in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 16th October 2009, 22:16
  5. Can't load the postgre driver!
    By brevleq in forum Installation and Deployment
    Replies: 6
    Last Post: 12th January 2008, 05:23

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.