Qt Creator to standalone - again (MinGW)



  • I have this great GUI I've developed with QtCreator (Windows 10 with Qt Createor 4.2.1 based on QT 5.8.0 MinGW) and now I just want to make a standalone executable for use on another Windows 10 PC.

    I've been a software/firmware developer for over 30 years (so I fully understand the static/dynamic linking aspects) and I'm just amazed that something that's as commonly needed as this is not just another button on the interface?

    I gave this set of directions try:

    https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

    but it made it to here:

    Building static Qt version 5.8.0
    Using MinGW from C:\Qt\Qt5.8.0\Tools\mingw530_32

    • cd qtbase
    • C:\Qt\Static\src\qt-everywhere-opensource-src-5.8.0\qtbase\configure.bat -top-level -static -debug-and-release -platform win32-g++ -prefix C:\Qt\Static\5.8.0 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests
      Please wait while bootstrapping configure ...
      Perl not found in PATH. Aborting.
      mingw32-make: *** No targets specified and no makefile found. Stop.
      mingw32-make: *** No rule to make target 'install'.
      Out-File : Could not find a part of the path 'C:\Qt\Static\5.8.0\mkspecs\win32-g++\qmake.conf'.
      At C:\Users\Mike\Downloads\windows-build-qt-static.ps1:178 char:6
    • "@ | Out-File -Append $File -Encoding Ascii
    •  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      • CategoryInfo : OpenError: (:) [Out-File], DirectoryNotFoundException
      • FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

    Press Enter to continue...:

    I've installed Perl and it appears to be in the PATH

    PS C:\Users\Mike> perl --version

    This is perl 5, version 24, subversion 1 (v5.24.1) built for MSWin32-x86-multi-thread-64int
    (with 1 registered patch, see perl -V for more detail)

    Copyright 1987-2017, Larry Wall

    Binary build 2402 [401627] provided by ActiveState http://www.ActiveState.com
    Built Jan 5 2017 01:57:19

    Perl may be copied only under the terms of either the Artistic License or the
    GNU General Public License, which may be found in the Perl 5 source kit.

    Complete documentation for Perl, including FAQ lists, should be found on
    this system using "man perl" or "perldoc perl". If you have access to the
    Internet, point your browser at http://www.perl.org/, the Perl Home Page.

    PS C:\Users\Mike>

    I tried Strawberry Perl as well - same results.

    Is there a known way to do this that actually works?


  • Lifetime Qt Champion

    Hi,

    Partly that's because while it might be practical to have a statically linked application, abiding by the constraint of LGPL regarding replacement of the libraries used to build your application is usually overkill for the developer.

    Then providing static builds for all the platforms and compiler supported (there's already six different builds only for windows) is simply not realistic in terms of man power and hardware.

    As for your main problem, likely a silly question but did you restart from scratch once you installed Perl ?

    On a side note, the usual way to deploy application on Windows is to use windeployqt.



  • Yes - I did restart the system. Never hurts to ask the simple ones!

    I'll look into the windeployqt - thanks.


  • Lifetime Qt Champion

    For tools needed, see also the Build Qt 5 from git guide, there might be some other clues that could prove useful.

    Also, I'd recommend building only the modules you need, that will save you time and space.



  • Looks like windeployqt will do the trick. Here's the recipe that worked for me:

    Windows 10, latest updates installed.
    Qt installed, mingw flavor.
    Application developed with QtCreator.

    Once I had all the bugs worked out I switch QtCreator to release mode - its the monitor looking icon on lower left edge of QtCreator just above the run button. Then I did a Build->Rebuild project just to freshen things up.

    I made a new directory on the desktop and copied into that directory the application.exe file - you can get the path to if you watch the application output when you run in inside QtCreator. It will look like this:

    Starting C:\Users\mike\Desktop\qt\build-LEDControl-Desktop_Qt_5_9_1_MinGW_32bit-Release\release\application.exe...

    So now you've a new directory with the .exe file in it.

    You need to add two things your PATH variable, the path to windeployqt, and the path the gcc compilers (in the tools directory):

    0_1504025951725_Path.JPG

    Now pop a command fresh command window and cd into the new directory with the application.exe file in it and type

    windeployqt application.exe

    You can copy that entire folder to a thumb drive and run it on another PC.

    Of course you may have a different version of Qt and so the paths above will be different, and of course your mileage may vary when you try to run it on a different PC, but as I said this worked for me for now.

    This feature could just be a button on QtCreator and life would easier for a lot of people.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.