Bug 770399 - undefined reference to QPSQLDriver::QPSQLDriver(pg_conn*, QObject*) in qt-postgresql-4.8.0-0.29
undefined reference to QPSQLDriver::QPSQLDriver(pg_conn*, QObject*) in qt-pos...
Product: Fedora
Classification: Fedora
Component: qt (Show other bugs)
x86_64 Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Ngo Than
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2011-12-26 05:14 EST by hristo ivanov
Modified: 2011-12-27 12:41 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2011-12-26 05:36:37 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description hristo ivanov 2011-12-26 05:14:17 EST
Description of problem:

Linking with the qt Postgresql Driver (version qt-postgresql-4.8.0-0.29) does not provide the custom constructor QPSQLDriver::QPSQLDriver(pg_conn*, QObject*) at link time, although it's present in the header file and in the QT Postgresql source package distributed.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.Use the following source:

#include <stdio.h>
#include <stdlib.h>
#include <QObject>
#include <QtSql/QSqlDatabase>
#include <QString>
#include <libpq-fe.h>
#include <QtSql/qsql_psql.h>

int main()
  PGconn* f_connection = PQconnectdb(
    QString( "host=localhost user=%1 password=%2 dbname=%3" )
    .arg( "username" )
    .arg( "password" )
    .arg( "database" )
  QPSQLDriver* f_driver = new QPSQLDriver( f_connection );
  QSqlDatabase::addDatabase( f_driver );
  return 0;

Actual results:
A linker error:
undefined reference to QPSQLDriver::QPSQLDriver(pg_conn*, QObject*)

Expected results:
Successful compilation
Comment 1 Kevin Kofler 2011-12-26 05:36:37 EST
This is private undocumented API and thus not exported from the shared library. (The symbol has hidden visibility.)
Comment 2 Kevin Kofler 2011-12-26 05:38:38 EST
(From the QSqlDriver documentation: "This class should not be used directly. Use QSqlDatabase instead." And QPSQLDriver is a database-specific subclass of QSqlDriver, thus even more private.)
Comment 3 hristo ivanov 2011-12-27 03:37:17 EST
There seems to be an inconsistency in the Qt documentation itself, please see here:


This is an intended behaviour -- the users access the underlying DB connection, utilizing advanced features (or, in my own implementation, the COPY statement) alongside the Qt API for SQL.

What is the original policy here? Should the API be allowed or not?

I have fixed my urgent problem with duplicating the QPSQLDriver code in my application, adding the changes needed to access the connection directly. Thus, I'm leaving the bug as closed.
Comment 4 Kevin Kofler 2011-12-27 12:41:02 EST
The upstream documentation you linked also says: "If you do this, it is recommended that you include the driver code in your application." which is what you're doing now. Your software probably won't pass Fedora review that way (bundling library code is very much frowned upon), but since upstream is not willing to support that API as a public API, it's either that or not using that API at all.

Note You need to log in before you can comment on or make changes to this bug.