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. [SOLVED] PostgreSQL linker error

[SOLVED] PostgreSQL linker error

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 5.3k Views
  • 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.
  • M Offline
    M Offline
    maxim.prishchepa
    wrote on last edited by
    #1

    Hi! I compile PostgreSQL with "this":http://doc.qt.nokia.com/4.5/sql-driver.html#how-to-build-the-qpsql-plugin-on-windows instruction, build without problem, then try use this driver, when i write this code:
    @ QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("localhost");
    db.setDatabaseName("testdb");
    db.setUserName("gorans");
    db.setPassword("");
    if (!db.open())
    {
    ui.textEdit->append(QString("%1: "%2 %3"").arg(QDateTime::currentDateTime().toString("hh:MM:ss")).arg(QObject::tr("DB not found:")).arg(db.lastError().text()));
    }
    @

    i have result: 11:04:15: "DB not found: Driver not loaded Driver not loaded"

    when i try use this code (found them at the assistent):
    @#include "qtdir/src/sql/drivers/psql/qsql_psql.cpp"

    PGconn *con = PQconnectdb("host=server user=bart password=simpson dbname=springfield");
    QPSQLDriver *drv = new QPSQLDriver(con);
    QSqlDatabase db = QSqlDatabase::addDatabase(drv); // becomes the new default connection
    QSqlQuery query;
    query.exec("SELECT NAME, ID FROM STAFF");@

    i have trouble with linker:

    test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) const QPSQLDriver::`vftable'" (_imp??_7QPSQLDriver@@6B@) referenced in function "public: __thiscall QPSQLDriver::QPSQLDriver(class QObject *)" (??0QPSQLDriver@@QAE@PAVQObject@@@Z)

    1>test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QString __cdecl QPSQLDriver::tr(char const *,char const *)" (_imp?tr@QPSQLDriver@@SA?AVQString@@PBD0@Z) referenced in function "public: virtual bool __thiscall QPSQLDriver::open(class QString const &,class QString const &,class QString const &,class QString const &,int,class QString const &)" (?open@QPSQLDriver@@UAE_NABVQString@@000H0@Z)

    1>test.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QPSQLDriver::metaObject(void)const " (?metaObject@QPSQLDriver@@UBEPBUQMetaObject@@XZ)

    1>test.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QPSQLDriver::qt_metacast(char const *)" (?qt_metacast@QPSQLDriver@@UAEPAXPBD@Z)

    1>test.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QPSQLDriver::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QPSQLDriver@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

    some one know, what lib's i need link to my project for resolve this issue or how to correct register driver?

    ps: i add libpq.lib to current project

    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VanDerSam
      wrote on last edited by
      #2

      I think that the Qt-driver(plugin) for postgresql depends on dynamic library libpq.dll. It doesn't find it and gives out errors.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxim.prishchepa
        wrote on last edited by
        #3

        I try copy libqp.dll to plugin QtDir\plugins\sqldrivers this is not resolve an issue, then add to the PATH PostgreSQL lib folder this is not reslove my issue to :(

        any other ideas?

        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VanDerSam
          wrote on last edited by
          #4

          I use MinGW version of Qt. I copied libpq.dll file in BIN subdirectory of Qt distribution. It works for me.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maxim.prishchepa
            wrote on last edited by
            #5

            i forget to write, i use visual studio and nmake for compiling, Qt installing from distributive for MSVC2008.

            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maxim.prishchepa
              wrote on last edited by
              #6

              I add dependence to dll's which contains at the PostgreSQL/bin folder, and driver start work.

              tnx a lot All 4 help!

              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

              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