A
A
Alexander2015-06-18 19:58:16
Qt
Alexander, 2015-06-18 19:58:16

How to build a dll statically using Qt (windows)?

There is a static build of Qt. The executable (*.exe) built with this assembly has a size of approximately ~12MB and runs normally.
But the library fails to build. More precisely, it is going to assemble, it has a size of ~18MB, but when you try to connect it, the application crashes with the error << This application failed to start because it could not find or load the Qt platform plugin "windows" >>.
Everything. The message doesn't even mention what plugins are detected.

  • I tried copying the plugin " platforms/qwindows.dll " to the project folder - didn't help;
  • copied all the plugins together with the "platforms" folder and separately from it to the folder with the application - did not help;
  • copied additional libraries icu*XX.dll , libgcc*.dll , libstdc*.dll , libEGL , libGLES to the project folder - to no avail;
  • I tried copying all these libraries to " windows/system32 " folder - didn't help either...

I looked all over the Internet and found this solution , but after adding qwindows.lib to the project, the library is somehow not fully linked, it "looses" by 5MB at once and now its weight is ~ 12MB, and when you try to connect it in the application I get a standard error that the file " Qt5Core.dll " was not found, and after it all the other dependencies: Qt5Gui , Qt5Network , Qt5Qml .... after adding all these libraries to the project folder, everything starts and works fine, but the distribution itself weighs almost 90MB =) and this is with static linking!?
  • The library without static linking weighs only 17KB, but requires a bunch of libs from Qt5 (almost 60MB);
  • with static linking and changes made - 12MB, but at the same time it also drags all Qt5 dependencies with it;
  • and the library built without adding qwindows.lib to the project weighs 18MB, but does not start at all...
How to be? Any ideas?
Here is the .pro file :
QT       += widgets qml quick network core gui

TARGET = phpqml
TEMPLATE = lib
CONFIG += static dll qt thread

SOURCES += phpqml.cpp

HEADERS += phpqml.h

#INCLUDEPATH = C:/Qt/Qt5.3.0_Static/include
INCLUDEPATH += C:/src/php-5.3.26\
    C:/src/php-5.3.26/main\
    C:/src/php-5.3.26/Zend\
    C:/src/php-5.3.26/sapi\
    C:/src/php-5.3.26/TSRM

LIBS += -L$$PWD/../../../src/php-5.3.26-/dev/ -lphp5ts\
        -L$$PWD/../../../Qt/Qt5.3.0_Static/plugins/platforms/ -lqwindows

INCLUDEPATH += $$PWD/../../../src/php-5.3.26
DEPENDPATH += $$PWD/../../../src/php-5.3.26

OTHER_FILES += \
    phpqml.qml

Header .h :
#include <QApplication>
#include <QQuickView>
#include <QtPlugin>
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin)
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TriKrista, 2015-06-19
@TriKrista

I haven't done this in a long time.
But, as far as I remember, it is necessary to rebuild Qt in static.
But, the size will not change much, it will just be a single piece. As for me, dynamic assembly is better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question