Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PostgreSQL drivers build and use
Forum Updated to NodeBB v4.3 + New Features

PostgreSQL drivers build and use

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thuthuka
    wrote on last edited by
    #1

    I am trying to get a Qt connection to PostgreSQL. I have made a few changes to get things to work
    So I'll give the details so you know where I am and how I got there.

    Current Sys config:
    Windows 8 64-bit
    postgresql-9.2.4
    Qt 5.0.2 mingw 32- bit

    First I build the ..\5.0.2\Src\qtbase\src\plugins\sqldrivers\psql\psql.pro
    to point the psql.pro to my PostgreSQL I added the following to my psql.pro

    @
    INCLUDEPATH += $$quote("C:/pgsql/include/")
    @

    But when I did that I got
    .. \mingw\i686-w64-mingw32\include\sys\timeb.h:90: error: previous definition of 'struct timespec'

    Which is a conflict between the two following defines. One from Qt and another from PostgreSQL

    timeb.h
    @
    #ifndef _TIMESPEC_DEFINED
    #define _TIMESPEC_DEFINED
    struct timespec {
    time_t tv_sec; /* Seconds /
    long tv_nsec; /
    Nanoseconds */
    };
    @

    pgsql\include\pthread.h
    @
    #ifndef HAVE_STRUCT_TIMESPEC
    #define HAVE_STRUCT_TIMESPEC 1
    struct timespec {
    long tv_sec;
    long tv_nsec;
    };
    #endif /* HAVE_STRUCT_TIMESPEC */
    @

    To fix this I added this to my psql.pro
    @
    DEFINES += HAVE_STRUCT_TIMESPEC
    @

    This build but for some strange reason put the files in a new folder C:\plugins\sqldrivers
    libqsqlpsql.a
    libqsqlpsqld.a
    qsqlpsql.dll
    qsqlpsqld.dll

    I copied them to here
    ..\5.0.2\mingw47_32\plugins\sqldrivers\

    When I try and use this in QT now I am getting the following.
    The code

    @ qDebug() << "Available drivers: " << QSqlDatabase::drivers();
    *db = QSqlDatabase::addDatabase("QPSQL");
    qDebug() << "addDatabase() " << (db->isValid() ? "VALID" : "ERROR");
    db->setUserName("postgres");
    db->setPassword("postgres");
    db->setDatabaseName(DBName);
    db->open();
    @

    gives me the following errors:

    @Available drivers: ("QSQLITE", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    addDatabase() ERROR
    Available drivers: ("QSQLITE", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    can't find linker symbol for virtual table for QSqlDriver' value found QSqlDatabasePrivate::shared_null()::dr' instead
    can't find linker symbol for virtual table for QSqlDriver' value found QSqlDatabasePrivate::shared_null()::dr' instead
    can't find linker symbol for virtual table for QSqlDriver' value found QSqlDatabasePrivate::shared_null()::dr' instead
    can't find linker symbol for virtual table for QSqlDriver' value found QSqlDatabasePrivate::shared_null()::dr' instead
    can't find linker symbol for virtual table for QSqlDriver' value found QSqlDatabasePrivate::shared_null()::dr' instead
    can't find linker symbol for virtual table for QObjectData' value found QSqlDatabasePrivate::shared_null()::dr' instead
    can't find linker symbol for virtual table for QObjectData' value found QSqlDatabasePrivate::shared_null()::dr' instead
    can't find linker symbol for virtual table for QObjectPrivate' value found QSqlDatabasePrivate::shared_null()::dr' instead
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    Debugging has finished
    @

    Have I build the PostgreSQL drivers incorrectly?

    Do I need to do something other than place the drivers into the \plugins\sqldrivers\ dir?

    edit
    I have just tried putting QTPLUGIN += qsqlpsql into my test.pro file but it does not seem to have any affect.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved