Qt World Summit: Submit your Presentation

Problems using QT library with QT application

  • Hello there. Would appriciate some help I am having with a problem using my own custom dll (yes this is under windows, for some reason I suspect it falls down to how windows handles threading, the library runs just fine under linux).

    The library is being used within another Qt application so I initialize QApplication before I use the .dll

    Still I get the message "QEventLoop: Cannot be used without QApplication", when I run the debug version. If I build the release version it works fine. I have built the library separately for release and debug and defined them in the .pri project file.

    I also get some warnings:

    "warning: 'Licensevalidator::staticMetaObject' redeclared without dllimport attribute after being referenced with dll linkage"

    which I suspect might be related but not the sole cause, since I get the same errors when bulding release and as mentioned the release executable works fine for some weird reason.

    Where do I start to troubleshoot and solve this?

  • @helgur

    First of all I would check that both application and dlls are built using the same CRTs ( toolchain and even debug/release matters ).

    If everything is the same, second question is why did you mention threading. Usage of dll and threading are kind of unrelated.

    Usually I would expect such problem if you have static objects in dlls. They are going to be instantiated before QApplication.

  • Both use the same toolchain (mingw32-make, qmake, win32g++), as for the threading issue this is more speculating on my part since it works fine under other operating systems besides windows.

  • Lifetime Qt Champion


    What is Licensevalidator ? A widget ? A static one ?

  • @helgur

    The difference has nothing to do with threads, but there might be difference in initialization order.
    And 90% of similar problems I've seen are related to static object initialization order,
    In any cases something is mostly likely instantiated before QApplication probably when dll is loaded.

  • I'll review this at a later time. As I said, the same code runs perfectly well when I compile it on Debian Mint, so if it was related to the initialization order of my objects, I would have ran into issues there aswell wouldn't I?

  • Lifetime Qt Champion

    Linux and Windows are pretty different when it comes to dll handling. Did you export your classes/methods properly ?

  • @SGaist

    Here is the header files (omitted some code). I had to use pastebin for this, because when I tried to wrap the code tags in '@' the forum acted up (the preview pane at least went nuts)





    Pro file:


  • Hi, could you also pastebin the licensevalidator.cpp file? Would help to spot the problem...

Log in to reply