Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Problems using QT library with QT application

    General and Desktop
    dll libraries
    4
    9
    3036
    Loading More Posts
    • 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.
    • H
      helgur last edited by

      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?

      A 1 Reply Last reply Reply Quote 0
      • A
        alex_malyu @helgur last edited by alex_malyu

        @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.

        1 Reply Last reply Reply Quote 0
        • H
          helgur last edited by

          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.

          A 1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            What is Licensevalidator ? A widget ? A static one ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • A
              alex_malyu @helgur last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • H
                helgur last edited by

                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?

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

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

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  H 1 Reply Last reply Reply Quote 0
                  • H
                    helgur @SGaist last edited by helgur

                    @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)

                    licensevalidator.h:

                    http://pastebin.com/QYqdfezh

                    licensevalidator_global.h:

                    http://pastebin.com/xv8VAgaY

                    Pro file:

                    http://pastebin.com/HPxHhVPL

                    1 Reply Last reply Reply Quote 0
                    • hskoglund
                      hskoglund last edited by

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

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post