Static build PostgreSQL in app

  • I have problem to static link my postgress plugin to app. The output compilation fault is that:

    undefined reference to `qt_static_plugin_qsqlpsql()'
    ./release\managament_plugin_import.o:managament_plugin_import.cpp:(.text.startup+0x26): undefined reference to `qt_static_plugin_QPSQLDriverPlugin()'

    This is my pro file:

    QT += core gui sql
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    #CONFIG += plugin static
    CONFIG += c++11 static
    QTPLUGIN += qsqlpsql
    #PLUGIN_TYPE = sqldrivers
    #INCLUDEPATH += C:\PostgreSQL\9.2\include
    #PRE_TARGETDEPS += C:\Qt\5.5\Src\qtbase\plugins\sqldrivers\libpq.dll
    #LIBS += -L$$PWD\sqldrivers\qsqlpsql.dll
    #LIBS += -LC:\Qt\5.5\Src\qtbase\plugins\sqldrivers\libqsqlpsql.a
    #PRE_TARGETDEPS += C:\Qt\5.5\Src\qtbase\plugins\sqldrivers\libpq.dll
    #QMAKE_LFLAGS += -static -static-libgcc -static-libstdc++ -lpthread

    as you see I try many ways to do this. I don know what is wrong because I added to my main.cpp:

    #include <QSqlDriverPlugin>
    #include <QtCore/QtPlugin> 

    I don't know should I add -qt-sql-<driver> and how. because If I add to makefile.release nothing change?
    Please help, I try do this cople days and nothing change.

  • Lifetime Qt Champion


    Did you compile Qt statically ?

  • Yes I compile qt staticly.

  • Lifetime Qt Champion

    Did you build the PostgreSQL plugin as part of your build ?
    If not then follow the documentation about QtSQL plugin build.

    Otherwise, rebuild Qt and include the driver directly but you'll have to do it from a clean build.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.