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. Static Builds not Working
Forum Updated to NodeBB v4.3 + New Features

Static Builds not Working

Scheduled Pinned Locked Moved Solved General and Desktop
static buildstatic5.10.1nmakemsvc2015
19 Posts 3 Posters 8.3k Views 3 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    It don't sound very static. ;)

    Compile release version first.
    Close Creator/VS
    Then could you try on the "debug machine" to rename the Qt folder so it cant find dlls from there

    and then go to build folder and double click the .exe
    and see if it still runs.

    E 1 Reply Last reply
    1
    • E ed-wright

      Hi Qt Forum!

      I am having some issues when i try to deploy a static build of my Qt Project.

      FYI i am using the following software:
      Qt Creator 4.5.1
      Qt 5.10.1
      Project Build Kit: Desktop Qt 5.10.1 MSVC2015 64Bit

      My Problem
      I can successfully build the software and run it on the debug machine but when i deploy it to another windows PC the error, This application failed to start because it could not find or load the Qt platform plugin "windows".

      Solutions Attempted So Far
      I have deleted the build directory and rebuilt it, then using windeployqt that explicitly called from C:\QT\Qt5.10.1\5.10.1\msvc2015_64\bin. That did not work.

      Copying all the Qt*.dll and Qt*d.dll over separately helped it as the previous step generated "Qt5Core is missing" even if it was in the directory, i assume this means that windeployqt is using dll's from an incorrect location.

      I have tried moving over the /platforms/qwindowsd.dll, in fact i did a search and moved over every copy of qwindowsd.dll and qwindows.dll and tried them all and they didnt stop the "could not find or load the Qt platform plugin "windows"." issue.

      I have tried it as a 32 bit application with MSVC2015 (Project Build Kit: Desktop Qt 5.10.1 MSVC2015 32Bit) and it build successfully and ran on my build PC but again did not work on the deployment PC with the same error.

      Furthermore, i have also tried building a new blank application and deploying it on the target machine and it has exactly the same error.

      Thanks in Advance

      This is my .pro File

      QT       += core gui network
      #CONFIG += static
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      INCLUDEPATH += "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10240.0\\ucrt"
      
      LIBS += -L"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10240.0\\ucrt\\x64"
      #LIBS += -L"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10240.0\\ucrt\\x86"
      
      TARGET = APPLICATION_NAME
      TEMPLATE = app
      
      
      SOURCES += main.cpp\
          class1.cpp \
          class2.cpp \
          class3.cpp \
          class4.cpp \
          class5.cpp \
          class6.cpp \
          class7.cpp \
          class8.cpp \
          class9.cpp \
          class10.cpp
      
      HEADERS  += class1.h \
          class2.h \
          class3.h \
          class4.h \
          class5.h \
          class6.h \
          class7.h \
          class8.h \
          class9.h \
          class10.h
      
      FORMS    += mainwindow.ui
      
      #QMAKE_CFLAGS_RELEASE += /MT
      #QMAKE_CXXFLAGS_RELEASE += /MT
      #QMAKE_CFLAGS_RELEASE -= -MD
      #QMAKE_CXXFLAGS_RELEASE -= -MD
      

      Please Note that names may have been changed due to the commercially sensitive nature of this project

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #3

      @ed-wright

      1. your project is not compiled statically (according to the .pro file you've posted)
      2. you need to have Qt built statically too(!!)
      3. for static plugins (also for platform plugins of course) you need to call Q_IMPORT_PLUGIN to include them statically into your application. See this for example

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      3
      • mrjjM mrjj

        Hi
        It don't sound very static. ;)

        Compile release version first.
        Close Creator/VS
        Then could you try on the "debug machine" to rename the Qt folder so it cant find dlls from there

        and then go to build folder and double click the .exe
        and see if it still runs.

        E Offline
        E Offline
        ed-wright
        wrote on last edited by ed-wright
        #4

        @mrjj Thanks for your reply, i got following error on my build machine "The application was unable to start correctly (0xc000007b). Click OK to close the application"

        With the QT folder back to normal it gives the error " The procedure entry point ?data@QNetworkDatagram@@QEBA?AAVQByteArray@@XZ could not be located in the dynamic link library Qt5Network.dll"

        mrjjM 1 Reply Last reply
        0
        • E ed-wright

          @mrjj Thanks for your reply, i got following error on my build machine "The application was unable to start correctly (0xc000007b). Click OK to close the application"

          With the QT folder back to normal it gives the error " The procedure entry point ?data@QNetworkDatagram@@QEBA?AAVQByteArray@@XZ could not be located in the dynamic link library Qt5Network.dll"

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #5

          @ed-wright
          Ok, so its really not build as static.
          Did you follow a guide to make a Qt static version ?
          In case, yes, which one ?
          Normally, there comes a new kit when you compiled the new Qt verion.
          And you need to select that for the app.

          Also as a note. Using static linking requires a Qt license.
          Its not available as open source, unless your app is also open source. ( which seems not to be the case)
          Since you seems to be a license holder, there is also the option to get direct support form Qt Company versus this free user forum.

          Also, you surely means static ? Static means it wont need any DLLs next to exe but all is compiled into the .exe.
          If you mean more like standalone. (outside creator)
          Then you just need to get the needed Dlls in the same folder as exe and it will run outside creator.
          I use this site for info
          http://www.tripleboot.org/?p=138

          1 Reply Last reply
          1
          • E Offline
            E Offline
            ed-wright
            wrote on last edited by
            #6

            @raven-worx Thanks for your reply

            1. If I uncomment the line CONFIG += static, should this make my project statically compiled?
            2. Is this a download or do i have to build this. I have a Qt Commercial licence.
            3. So if i want to statically link QNetwork for example do add QTPLUGIN += qnetwork (i am reading the link you sent as we speak)

            @mrjj Thanks again for your reply, I do have a commercial licence but i happy to stay on here if it helps someone else in the future.
            What is the process for statically linking Qt into my project?

            What I ultimately want is a stand-alone application (just an .exe) that i can run to start my application no DLLs

            mrjjM 1 Reply Last reply
            0
            • E ed-wright

              @raven-worx Thanks for your reply

              1. If I uncomment the line CONFIG += static, should this make my project statically compiled?
              2. Is this a download or do i have to build this. I have a Qt Commercial licence.
              3. So if i want to statically link QNetwork for example do add QTPLUGIN += qnetwork (i am reading the link you sent as we speak)

              @mrjj Thanks again for your reply, I do have a commercial licence but i happy to stay on here if it helps someone else in the future.
              What is the process for statically linking Qt into my project?

              What I ultimately want is a stand-alone application (just an .exe) that i can run to start my application no DLLs

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #7

              @ed-wright
              Hi
              Then you have to build a static Qt version.
              I have seen static pre-build for Qt Device Creation but im not sure
              if they have one for Desktop. (I would ask, it takes quite some time to compile
              a full Qt unless your pc is epic)
              this is a good start read
              https://wiki.qt.io/Build_Standalone_Qt_Application_for_Windows
              and also
              http://amin-ahmadi.com/2016/09/22/how-to-build-qt-5-7-statically-using-msvc14-microsoft-visual-studio-2015/
              but first start with
              http://doc.qt.io/qt-5/build-sources.html
              and make sure you install all it mentions from
              http://doc.qt.io/qt-5/windows-requirements.html
              perl, and also python i recall. This is a must do or
              it will compile for long time and then fail.
              Also, use a good pc. Dual core 1.5 ghz slim laptop will take ages.

              1 Reply Last reply
              1
              • E Offline
                E Offline
                ed-wright
                wrote on last edited by
                #8

                @mrjj

                Back to your original comment, I manually moved over all the Qt5*.dll from C:\QT\Qt5.10.1\5.10.1\msvc2015_64\bin and then ran windeployqt.exe it now executes.

                Changes
                It is now the release version
                My pro is now changed to uncomment the line "#CONFIG += static"
                My C:/QT folder is not currently called this as per your recommendation

                mrjjM 1 Reply Last reply
                0
                • E ed-wright

                  @mrjj

                  Back to your original comment, I manually moved over all the Qt5*.dll from C:\QT\Qt5.10.1\5.10.1\msvc2015_64\bin and then ran windeployqt.exe it now executes.

                  Changes
                  It is now the release version
                  My pro is now changed to uncomment the line "#CONFIG += static"
                  My C:/QT folder is not currently called this as per your recommendation

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @ed-wright
                  Ok, so you successfully made a deployment folder.
                  Good work. Its also handy to have to check out stuff.

                  But its not static as that is some more work before thats possible,

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    ed-wright
                    wrote on last edited by
                    #10

                    @mrjj

                    I have gone into my Qt account and started downloading qt-everywhere-src-5.10.1.zip, i hope this is the correct download for the static build of Qt. Its Description is, Qt Source Package, Full Framework with Windows style line endings.

                    mrjjM 1 Reply Last reply
                    0
                    • E ed-wright

                      @mrjj

                      I have gone into my Qt account and started downloading qt-everywhere-src-5.10.1.zip, i hope this is the correct download for the static build of Qt. Its Description is, Qt Source Package, Full Framework with Windows style line endings.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @ed-wright
                      Yes, that is the source code. But there is also Qt 5.11
                      but i assume you been using 5.10.1 ? ( its perfectly fine)
                      You will then compile a static version from it.
                      Make sure to reads docs carefully as else it fails and you been wasting hours looking at it compiling.

                      E 1 Reply Last reply
                      1
                      • mrjjM mrjj

                        @ed-wright
                        Yes, that is the source code. But there is also Qt 5.11
                        but i assume you been using 5.10.1 ? ( its perfectly fine)
                        You will then compile a static version from it.
                        Make sure to reads docs carefully as else it fails and you been wasting hours looking at it compiling.

                        E Offline
                        E Offline
                        ed-wright
                        wrote on last edited by
                        #12

                        @mrjj
                        As im currently using Qt5.10.1 on Qt Creator so i thought i would stick to the same version.

                        mrjjM 1 Reply Last reply
                        0
                        • E ed-wright

                          @mrjj
                          As im currently using Qt5.10.1 on Qt Creator so i thought i would stick to the same version.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          @ed-wright
                          That is fine. Not an issue. just wanted to be clear up front as the
                          compiling time is not trivial .)

                          1 Reply Last reply
                          1
                          • E Offline
                            E Offline
                            ed-wright
                            wrote on last edited by ed-wright
                            #14

                            I have been trying to compile the static version of Qt now and have run into a few issues.
                            Following http://doc.qt.io/qt-5/windows-building.html to try to build the
                            static version of Qt.

                            STEP 1
                            As i use Qt Creator and i have put the License into the prompt this step is
                            done

                            STEP 2
                            I already have a directory called C:\QT\Qt5.10.1, but from the downloads page
                            in my account i also have downloaded (Qt Source Package, Full Framework with
                            Windows style line endings ) and it is unpacked and located at C:\QT\qt-
                            everywhere-src-5.10.1, my project is currently using the first path.

                            STEP 3
                            With the environment variables, in my PATH i have
                            C:\QT\vs2015\qt5.6.1-64\5.6\msvc2015_64\bin, i do not think this is correct as
                            i want to be using 5.10.1 with msvs2015 so i think it needs to be.
                            C:\QT\Qt5.10.1\5.10.1\msvc2015_64\bin is this correct?

                            Anyway, following the guide my file qt5vars.cmd has the following:

                            REM Set up \Microsoft Visual Studio 14, where <arch> is \c amd64, \c
                            x86, etc.
                            CALL "C:\Program Files (x86)\Microsoft Visual Studio
                            14.0\VC\vcvarsall.bat" amd64
                            SET _ROOT=C:\QT\qt-everywhere-src-5.10.1
                            SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
                            REM Uncomment the below line when using a git checkout of the source
                            repository
                            REM SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
                            SET _ROOT=

                            NOTE: i am trying to use the downloaded (Qt Source Package, Full Framework
                            with Windows style line endings) not the normal 5.10.1 build.

                            NOTE2: This produces the following when running in the cmd off the shortcut on
                            the desktop:

                            C:\WINDOWS>REM Set up \Microsoft Visual Studio 14, where <arch> is \c
                            amd64, \c
                            x86, etc.

                            C:\WINDOWS>CALL "C:\Program Files (x86)\Microsoft Visual Studio
                            14.0\VC\vcvarsal
                            l.bat" amd64

                            STEP 4

                            Using the Developer Command Prompt for VS2015 i navigate to C:\QT\qt-
                            everywhere-src-5.10.1

                            and run the following configure -debug -nomake examples -nomake tests -skip
                            qtwebengine -opensource

                            i get the following errors

                            NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual
                            Studio 14.0
                            \VC\BIN\cl.EXE"' : return code '0x2'

                            1 Reply Last reply
                            0
                            • E Offline
                              E Offline
                              ed-wright
                              wrote on last edited by ed-wright
                              #15

                              @mrjj

                              Okay an update, Still not working but got a little further.

                              I have added the line:
                              set CL=/I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt"

                              to the file, C:\QT\qt-everywhere-src-5.10.1\configure.bat

                              it now progresses further BUT now i get this error:

                              LINK : fatal error LNK1104: cannot open file 'libucrt.lib'
                              NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.EXE"' : return code '0x450'
                              Stop.

                              im trying to find libucrt.lib as we speak

                              mrjjM 1 Reply Last reply
                              0
                              • E ed-wright

                                @mrjj

                                Okay an update, Still not working but got a little further.

                                I have added the line:
                                set CL=/I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt"

                                to the file, C:\QT\qt-everywhere-src-5.10.1\configure.bat

                                it now progresses further BUT now i get this error:

                                LINK : fatal error LNK1104: cannot open file 'libucrt.lib'
                                NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.EXE"' : return code '0x450'
                                Stop.

                                im trying to find libucrt.lib as we speak

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                Hi
                                Good work.
                                I have not seen that one before, but it seems to be related to static linking
                                https://stackoverflow.com/questions/35805113/visual-studio-2015-run-time-dependencies-or-how-to-get-rid-of-universal-crt

                                1 Reply Last reply
                                1
                                • E Offline
                                  E Offline
                                  ed-wright
                                  wrote on last edited by ed-wright
                                  #17

                                  @mrjj

                                  Adding the following to my configure.bat located in the C:\QT\qt-everywhere-src-5.10.1 directory allowed me to overcome this problem.

                                  set INCLUDE=%INCLUDE%;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
                                  set LIB=%LIB%;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86
                                  

                                  Onto the next issue now.

                                  I have successfully run the command

                                  configure -debug -nomake examples -nomake tests -skip qtwebengine -opensource -static
                                  

                                  The next part of the guide states that the following command should be run.

                                  nmake
                                  

                                  Once running it went for a few minutes and then produced the following error

                                  Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
                                  Copyright (C) Microsoft Corporation.  All rights reserved.
                                  
                                          cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -utf-8 -W0 /Fd..\..\..\lib\qtpcre2d.pdb -DUNICODE -D_UNICODE -DWIN32 -DPCRE2_CODE_UNIT_WIDTH=16 -DPCRE2_STATIC -DQT_NO_NARROWING_CONVER
                                  SIONS_IN_CONNECT -DHAVE_CONFIG_H -DQT_NO_DYNAMIC_CAST -DQT_NO_EXCEPTIONS -I. -Isrc -I..\..\..\mkspecs\win32-msvc -Fo.obj\debug\ @C:\Users\T0187208\AppData\Local\Temp\nmF7A.tmp
                                  pcre2_auto_possess.c
                                  pcre2_chartables.c
                                  pcre2_compile.c
                                  pcre2_config.c
                                  pcre2_context.c
                                  pcre2_dfa_match.c
                                  pcre2_error.c
                                  pcre2_find_bracket.c
                                  pcre2_jit_compile.c
                                  pcre2_maketables.c
                                  pcre2_match.c
                                  pcre2_match_data.c
                                  pcre2_newline.c
                                  pcre2_ord2utf.c
                                  pcre2_pattern_info.c
                                  pcre2_serialize.c
                                  pcre2_string_utils.c
                                  pcre2_study.c
                                  pcre2_substitute.c
                                  pcre2_substring.c
                                  Generating Code...
                                  Compiling...
                                  pcre2_tables.c
                                  pcre2_ucd.c
                                  pcre2_valid_utf.c
                                  pcre2_xclass.c
                                  Generating Code...
                                          lib /NOLOGO  /OUT:..\..\..\lib\qtpcre2d.lib @C:\Users\T0187208\AppData\Local\Temp\nm1B7D.tmp
                                          cd corelib\ && ( if not exist Makefile C:\QT\qt-everywhere-src-5.10.1\qtbase\bin\qmake.exe -o Makefile C:\QT\qt-everywhere-src-5.10.1\qtbase\src\corelib\corelib.pro ) && "C:\Program Files (x86
                                  )\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe" -f Makefile
                                  ASSERT: "isAbsolutePath(baseDir)" in file C:\QT\qt-everywhere-src-5.10.1\qtbase\qmake\library\ioutils.cpp, line 106
                                  NMAKE : fatal error U1077: 'cd' : return code '0x3'
                                  Stop.
                                  NMAKE : fatal error U1077: 'cd' : return code '0x2'
                                  Stop.
                                  NMAKE : fatal error U1077: 'cd' : return code '0x2'
                                  Stop.
                                  

                                  This is omitting some of the previous command line output that all worked correctly, this is where it crashed.

                                  Do you have any idea?

                                  1 Reply Last reply
                                  0
                                  • E Offline
                                    E Offline
                                    ed-wright
                                    wrote on last edited by
                                    #18

                                    So part of the problem was that my default prefix for the configure command was incorrect.

                                    So going back and running the following worked.

                                    configure -debug -nomake examples -nomake tests -skip qtwebengine -opensource -static -prefix C:\QT\qt-everywhere-src-5.10.1 -redo -recheck-all
                                    

                                    Then to Build

                                    nmake
                                    
                                    1 Reply Last reply
                                    1
                                    • mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      Super good work.
                                      Thanks for updating on the way. will be helpful for others.

                                      1 Reply Last reply
                                      1

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved