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. Problems using QT library with QT application
Forum Updated to NodeBB v4.3 + New Features

Problems using QT library with QT application

Scheduled Pinned Locked Moved General and Desktop
dlllibraries
9 Posts 4 Posters 3.3k Views 2 Watching
  • 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 Offline
    H Offline
    helgur
    wrote on last edited by
    #1

    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
    0
    • H helgur

      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 Offline
      A Offline
      alex_malyu
      wrote on last edited by alex_malyu
      #2

      @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
      0
      • H Offline
        H Offline
        helgur
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0
          • H helgur

            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 Offline
            A Offline
            alex_malyu
            wrote on last edited by
            #5

            @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
            0
            • H Offline
              H Offline
              helgur
              wrote on last edited by
              #6

              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
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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
                0
                • SGaistS SGaist

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

                  H Offline
                  H Offline
                  helgur
                  wrote on last edited by helgur
                  #8

                  @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
                  0
                  • hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on last edited by
                    #9

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

                    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