2

After successfully building static QT and my application binary on Linux I moved to Windows to try out the same.

..\qt-everywhere-src-5.12.8\configure.bat -opensource -confirm-license -release -static -static-runtime -no-pch -optimize-size -opengl desktop -platform win32-g++ -prefix "C:\Qt\Static" -skip webengine -nomake tools -nomake tests -nomake examples
mingw32-make -j4 && mingw32-make install 

My development environment is Windows 10 x64, MinGW 7.3.0, QT 5.12.8 Static (Built with above cmdline). Now my problem with deployment is:

  • Strangely the binary is running on a fresh copy of Windows 10, but not on Windows 7. More surprisingly I tried to run the binary on Linux Wine, and voila it worked there as well.
  • Another problem is related to custom font loading, i.e. QFontDatabase::addApplicationFont also fails on Windows static build. Whereas same code works well on Linux static build or Windows dynamic QT linking. I tried Q_INIT_RESOURCE based on some stackoverflow post but that didn't help.

I tried reading several qt wiki articles but nothing has helped so far for both of the above problems.

Edit #1

Here is the font loading code which is failing on static build:

Q_INIT_RESOURCE(qml);
int idFont = QFontDatabase::addApplicationFont(":/fonts/Comfortaa-Bold.ttf");
if (idFont == -1)
{
    qDebug() <<"Failed to load font from resource";
    ....

Edit #2

There is a new hope. I have just tried building a simple widget application and build that statically with same Qt version. Now it works on fresh Windows 7. So I need to figure out why QML application is not working. Do I need to do anything specific for qml modules or plugin during Qt static build?

Edit #3

  • Fixed Windows 7 execution issue by changing VM settings.
  • Fixed the font loading issue by rebuilding Qt. This time I used Qt 5.15.0 and command line was:
configure.bat -opensource -confirm-license -prefix "C:\Qt\5.15.0-Static" -release -static -static-runtime -opengl desktop -platform win32-g++ -make libs -qt-libpng -qt-libjpeg -qt-freetype -qt-zlib -nomake tools -nomake examples -nomake tests -skip qttools
anupx73
  • 398
  • 5
  • 18

1 Answers1

0

The problem was with VirtualBox display driver which by default doesn't support OpenGL. When I turned on the 3D acceleration in VirtualBox settings the Qt Qml static application worked. This also justifies why my statically linked application worked on Windows 10 as those were installed on direct hardware, not on VM, thus was using proper underlying driver and opengl.

So this implies when you use -opengl desktop flag it uses underlying operating system's opengl library and even though mingw links with -lopenglw32 it still depends on system's opengl.

anupx73
  • 398
  • 5
  • 18