Qt Forum

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

    Solved Deploying a QApplication inside a DLL == platform plugin not found even if here

    General and Desktop
    deployment dll platform windeployqt qapplication
    2
    3
    390
    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.
    • A
      Aria-dvp last edited by Aria-dvp

      Hi fellow Qt devs!

      I am currently developing a C++ project using Qt5.14.2
      My final project has to be a DLL, because it's loaded in the CAD software Bentley's Microstation. Everything works fine on my computer, and the project is almost done : my QApplication is a singleton, the event loop run in a different Qthread, etc. It works!

      I first deployed the DLL on my own computer, thanks to windeployqt.exe, and it worked really fine. Almost done !
      Here my deployed folders :

      Project folder
      |-   D3Dcompiler_47.dll
      |-   libEGL.dll
      |-   libGLESv2.dll
      |-   Myproject.dll
      |-   opengl32sw.dll
      |-   Qt5Core.dll
      |-   Qt5Gui.dll
      |-   Qt5Svg.dll
      |-   Qt5Widgets.dll
      |
      |___ iconengines
      |      |-   qsvgicon.dll
      |
      |___ imageformats
      |      |-   qgif.dll
      |      |-   qicns.dll
      |      |-   qico.dll
      |      |-   qjpeg.dll
      |      |-   qsvg.dll
      |      |-   qtga.dll
      |      |-   qtiff.dll
      |      |-   qwbmp.dll
      |      |-   qwebp.dll
      |
      |___ platforms
      |      |-   qwindows.dll
      |
      |___ styles
      |      |-   qwindowsvistastyle.dll
      |
      |___ translations
             |-   qt_ar.qm
             |-   qt_bg.qm
             |-   qt_ca.qm
             |-   qt_cs.qm
             |-   qt_da.qm
             |-   qt_de.qm
             |-   qt_en.qm
             |-   qt_es.qm
             |-   qt_fi.qm
             |-   qt_fr.qm
             |-   qt_gd.qm
             |-   qt_he.qm
             |-   qt_hu.qm
             |-   qt_it.qm
             |-   qt_ja.qm
             |-   qt_ko.qm
             |-   qt_lv.qm
             |-   qt_pl.qm
             |-   qt_ru.qm
             |-   qt_sk.qm
             |-   qt_uk.qm
             |-   qt_zh_TW.qm
      

      The problem is : I used the same deployment on a test machine, in order to simulate a production environment. When I run Microstation and I attempt to launch my Qt Window, I have the well known error message "This application failed to start because not Qt platform plugin could be initialized", even if all the Qt's DLLs are here, next to Myproject.dll as you can see.

      In order to test, I tried to deploy a simple minimal Qt application (an exe this time) on the same machine, again thanks to windeployqt.exe, and it worked, so I suppose the problem is the DLL state. Why is it not working for my Myproject.dll ? Is it because the Qt's DLL are not in the same folder as Microstation.exe? Myproject.dll is in another folder on the C: harddrive, as I don't want to change anything in the installation folder of Microstation.
      I suppose my project worked on my computer thanks to QT_PATH. But on this new environment, this path variable is absent, the project doesn't seem to find any of the Qt DLL deployed.

      How should I deploy the dll in order to make my project viable on a production environnement, without touching the Microstation installation folders?

      I also tried to follow this solution from Stack Overflow by adding -platformpluginpath in the argv and the platforms folder's path :

      char *argv[] = { "QtGui", "-platformpluginpath", "C:/Project folder/platforms"};
      int argc = sizeof(argv) / sizeof(char*) - 1;
      

      But it only made my program crashs.

      I thank you by advance for your answers :) have a good day.

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

        Hi, indeed deploying a .dll instead of an .exe it's more tricky, since the normal solution of placing the Qt .dlls next to .exe file (i.e. in the same directory) is not feasible.

        But you have some other options, one is to add the path to the Qt files yourself via some C++ code, this has to be done before QApplication's constructor (because that's where the plugin loading occurs), say like this:

        ...
        QCoreApplication::addLibraryPath("C:/Project folder");
        QApplication a(argc,argv);
        ...
        1 Reply Last reply Reply Quote 4
        • hskoglund
          hskoglund last edited by

          Hi, indeed deploying a .dll instead of an .exe it's more tricky, since the normal solution of placing the Qt .dlls next to .exe file (i.e. in the same directory) is not feasible.

          But you have some other options, one is to add the path to the Qt files yourself via some C++ code, this has to be done before QApplication's constructor (because that's where the plugin loading occurs), say like this:

          ...
          QCoreApplication::addLibraryPath("C:/Project folder");
          QApplication a(argc,argv);
          ...
          1 Reply Last reply Reply Quote 4
          • A
            Aria-dvp last edited by

            Thank you @hskoglund for this option, it worked!
            This is the perfect solution for me, it's simple, and now I can use C++ variables for the install path of my DLL if needed.

            Thanks again!

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