Qt World Summit: Register Today!

Problem using static build lib in static build application on Linux

  • On my Linux box I got a static and dynamic install of Qt 4.8.0.
    I created a project, it builds and executes as a dynamic and a static build.
    Now I have moved some classes out of this project and create a library from them.
    It contains log in, change passwords dialogs (very simple) which we want to use in all our Qt projects.

    The library builds fine as a static and dynamic build (debug and release).
    I created a test program which includes this library. It builds either way fine.
    When the lib and the application are both build dynamically (debug and release) everything works.
    Now I did a static lib build and a static application build. It builds fine but I get the following crash:
    QWidget: Must construct a QApplication before a QPaintDevice
    Looking up the above error hasn't helped me.

    Is it even possible to do what I am trying to do? static lib in static app????
    As the dynamic build works fine I am a bit confused why it would not work.
    I have run ldd on the executable and no Qt library is listed.

    here is my test app project file:
    @QT += core gui

    TARGET = udp_test
    TEMPLATE = app
    INCLUDEPATH += /proj/jenosys/jebs/jebs_linux/qt_lib/ul
    /proj/jenosys/jebs/jebs_linux/qt_lib/ul_static_release # Need this to get ui_xxx.h

    LIBS += -L$$PWD/../../../jebs/jebs_linux/qt_lib/ul_static_release/ -lul

    QMAKE_LFLAGS += -Wl,--rpath=/proj/jenosys/jebs/jebs_linux/qt_lib/ul_static_release

    SOURCES += main.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui@

    Here is the code where I try to use the lib:
    @#include <QtGui/QApplication>
    #include "mainwindow.h"

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    MainWindow w;

    return a.exec&#40;&#41;;


    @#include <QtGui/QApplication>
    #include <QDebug>
    #include <QUdpSocket>
    #include <QMessageBox>
    #include <QDateTime>

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "ul_login.h"
    #include "ui_ul_login.h"

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    qDebug() << "befor login_dlg";
    ul_login_dlg   *xp_ul_login = new ul_login_dlg( 0, this );
    qDebug() << "after ul_login_dlg   *xp_ul_login";
    if ( xp_ul_login->exec&#40;&#41; == QDialog::Rejected )
        qDebug() << "Login dialog rejected";
    delete xp_ul_login;


    Thanks for your help!

Log in to reply