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. building a monolithic (standalone) program
Forum Updated to NodeBB v4.3 + New Features

building a monolithic (standalone) program

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 6 Posters 5.1k Views 4 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    I need to build a standalone Windows image. According to this link I need to build a static version of Qt, following the directions here.

    I try running the Powershell script and get this error:

    Building static Qt version 5.3.0
    ERROR: MinGW environment not found, no Qt prebuilt version?
    Press Enter to continue...:
    

    Not sure what to make of this, as I do have a prebuilt version of Qt. I seem to have two copies of MinGW:

    • C:\Qt\5.9.1\mingw53_32\bin
    • C:\Qt\Tools\mingw530_32\bin\gcc.exe

    I'm not familiar with Powershell...can someone tell me what I'm doing wrong here?

    Thanks...

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

      @mzimmers said in building a monolithic (standalone) program:

      C:\Qt\5.9.1\mingw53_32

      That should be it.
      Try to run
      C:\Qt\Qt5.9.1\5.9.1\mingw53_32\bin\qtenv2.bat
      before trying to run the recompile.

      Also note, that use Static linking your app should be open source
      or you should own a Qt licence. Else you be violating your terms of using Qt.

      J.HilkJ mzimmersM 2 Replies Last reply
      1
      • mrjjM mrjj

        @mzimmers said in building a monolithic (standalone) program:

        C:\Qt\5.9.1\mingw53_32

        That should be it.
        Try to run
        C:\Qt\Qt5.9.1\5.9.1\mingw53_32\bin\qtenv2.bat
        before trying to run the recompile.

        Also note, that use Static linking your app should be open source
        or you should own a Qt licence. Else you be violating your terms of using Qt.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @mrjj said in building a monolithic (standalone) program:

        Also note, that use Static linking your app should be open source
        or you should own a Qt licence. Else you be violating your terms of using Qt.

        I used to believe that only applies, if you compile(staticaly) a modified/customized Qt-Libary. If you compile the unchanges Source files, downloaded from the Qt-Webside, you're ok.

        But I may be wrong here as the last time I check this is years ago. Also the Qt - licensing part is super confusing anyway for any non nativ and non lawyer.


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        jsulmJ 1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          @mrjj said in building a monolithic (standalone) program:

          Also note, that use Static linking your app should be open source
          or you should own a Qt licence. Else you be violating your terms of using Qt.

          I used to believe that only applies, if you compile(staticaly) a modified/customized Qt-Libary. If you compile the unchanges Source files, downloaded from the Qt-Webside, you're ok.

          But I may be wrong here as the last time I check this is years ago. Also the Qt - licensing part is super confusing anyway for any non nativ and non lawyer.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @J.Hilk No, statically linking GPL code requires you to release your software under GPL as well. I doesn't matter whether you changed the GPL code or not.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          4
          • aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by aha_1980
            #5

            @J.Hilk said in building a monolithic (standalone) program:

            I used to believe that only applies, if you compile(staticaly) a modified/customized Qt-Libary. If you compile the unchanges Source files, downloaded from the Qt-Webside, you're ok.

            No, your'e not. The reason is, that if you link dynamically, every end-user can exchange the Qt libraries and update to a newer version (e.g. to avoid security holes).

            If you link statically, it's impossible to change anything without source code.

            This is of course nothing Qt specific, IMHO it applies to all GPL licensed programs. Disclaimer: I'm not a laywer.

            Edit: @jsulm was a bit faster :)

            Qt has to stay free or it will die.

            1 Reply Last reply
            4
            • mrjjM mrjj

              @mzimmers said in building a monolithic (standalone) program:

              C:\Qt\5.9.1\mingw53_32

              That should be it.
              Try to run
              C:\Qt\Qt5.9.1\5.9.1\mingw53_32\bin\qtenv2.bat
              before trying to run the recompile.

              Also note, that use Static linking your app should be open source
              or you should own a Qt licence. Else you be violating your terms of using Qt.

              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #6

              @mrjj I ran that .bat file; same results.

              I can't find anything in the instructions that suggest a needed precursor to this step; am I missing anything? (For example, the notes say it will download the Qt source, so I haven't done that.)

              Thanks...

              mrjjM 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @mrjj I ran that .bat file; same results.

                I can't find anything in the instructions that suggest a needed precursor to this step; am I missing anything? (For example, the notes say it will download the Qt source, so I haven't done that.)

                Thanks...

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

                @mzimmers
                Hi
                do you mean
                windows-build-qt-static.ps1 thing ?

                Sorry i have never used it. i installed the source via maintenance tool.

                mzimmersM 1 Reply Last reply
                0
                • mrjjM mrjj

                  @mzimmers
                  Hi
                  do you mean
                  windows-build-qt-static.ps1 thing ?

                  Sorry i have never used it. i installed the source via maintenance tool.

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #8

                  @mrjj Yeah, that's what I meant. I'm using the maintenance tool right now to download the source. I'm installing in a root directory C:\QtStatic so as not to interfere with my dynamic version. I guess once this is done, I actually install what I've built? (The instructions aren't entirely clear to me.)

                  1 Reply Last reply
                  0
                  • mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by
                    #9

                    I'm trying the Powershell script again. I found a couple items that needed changing (they could be modified through parameters, but I found it easier to simply edit the script). Now when I run, I get this error:

                    ERROR: Invalid value given for boolean command line option 'sql-sqlite'.
                    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.9.1\mkspecs\win32-g++\qmake.conf'.
                    At C:\Users\MZimmers\windows-build-qt-static.ps1:179 char:6
                    + "@ | Out-File -Append $File -Encoding Ascii
                    +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        + CategoryInfo          : OpenError: (:) [Out-File], DirectoryNotFoundException
                        + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
                    

                    I don't know whether the sql error is related to the real problem or not, but $File is defined as "$QtDir\mkspecs\win32-g++\qmake.conf" and C:\Qt\Static\5.9.1 is empty. Anyone have an idea what's going on here?

                    jsulmJ 1 Reply Last reply
                    0
                    • mzimmersM mzimmers

                      I'm trying the Powershell script again. I found a couple items that needed changing (they could be modified through parameters, but I found it easier to simply edit the script). Now when I run, I get this error:

                      ERROR: Invalid value given for boolean command line option 'sql-sqlite'.
                      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.9.1\mkspecs\win32-g++\qmake.conf'.
                      At C:\Users\MZimmers\windows-build-qt-static.ps1:179 char:6
                      + "@ | Out-File -Append $File -Encoding Ascii
                      +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                          + CategoryInfo          : OpenError: (:) [Out-File], DirectoryNotFoundException
                          + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
                      

                      I don't know whether the sql error is related to the real problem or not, but $File is defined as "$QtDir\mkspecs\win32-g++\qmake.conf" and C:\Qt\Static\5.9.1 is empty. Anyone have an idea what's going on here?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @mzimmers said in building a monolithic (standalone) program:

                      C:\Qt\Static\5.9.1 is empty

                      why is it empty? What is in C:\Qt\Static ?
                      Before you specified that Qt source code is in C:\QtStatic, why do you use C:\Qt\Static now?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • mzimmersM Offline
                        mzimmersM Offline
                        mzimmers
                        wrote on last edited by mzimmers
                        #11

                        The PS script installs into Qt/Static, or at least it's supposed to. I chose QtStatic before I realized the script used Qt/Static. According to my understanding of the web page, the script is supposed to download and populate that directory. I don't know why it's empty.

                        I have source in C:\QtStatic\5.9.1\Src from downloading it myself (not through the script). I suppose I could move it to Qt\Static\5.9.1\Src and see what the script would do. I was just under the impression the script would take care of the download for me, so I'm not sure what to do now.

                        1 Reply Last reply
                        0
                        • mzimmersM Offline
                          mzimmersM Offline
                          mzimmers
                          wrote on last edited by
                          #12

                          Can anyone help me with the steps involved in building a static Qt library? The script doesn't seem to be working for me, and I'd really like to get this done.

                          Thanks...

                          kshegunovK 1 Reply Last reply
                          0
                          • mzimmersM mzimmers

                            Can anyone help me with the steps involved in building a static Qt library? The script doesn't seem to be working for me, and I'd really like to get this done.

                            Thanks...

                            kshegunovK Offline
                            kshegunovK Offline
                            kshegunov
                            Moderators
                            wrote on last edited by
                            #13

                            @mzimmers said in building a monolithic (standalone) program:

                            script doesn't seem to be working for me, and I'd really like to get this done.

                            I don't know much about newer windows-es but usually it's just enough to open a command prompt (ming32 command prompt or MSVS command prompt), go to the Qt dir, call configure with the appropriate arguments (which would include -static in your case) wait a bit and then do mingw32-make/nmake to build. Although providing the dependencies for windows is pretty finicky in my experience.

                            Read and abide by the Qt Code of Conduct

                            mzimmersM 1 Reply Last reply
                            0
                            • kshegunovK kshegunov

                              @mzimmers said in building a monolithic (standalone) program:

                              script doesn't seem to be working for me, and I'd really like to get this done.

                              I don't know much about newer windows-es but usually it's just enough to open a command prompt (ming32 command prompt or MSVS command prompt), go to the Qt dir, call configure with the appropriate arguments (which would include -static in your case) wait a bit and then do mingw32-make/nmake to build. Although providing the dependencies for windows is pretty finicky in my experience.

                              mzimmersM Offline
                              mzimmersM Offline
                              mzimmers
                              wrote on last edited by
                              #14

                              @kshegunov by "the Qt dir" are you referring to the location of the source code?

                              kshegunovK 1 Reply Last reply
                              0
                              • mzimmersM mzimmers

                                @kshegunov by "the Qt dir" are you referring to the location of the source code?

                                kshegunovK Offline
                                kshegunovK Offline
                                kshegunov
                                Moderators
                                wrote on last edited by
                                #15

                                Yes, where the source code's been installed/downloaded.

                                Read and abide by the Qt Code of Conduct

                                1 Reply Last reply
                                0
                                • mzimmersM Offline
                                  mzimmersM Offline
                                  mzimmers
                                  wrote on last edited by
                                  #16

                                  OK I copied the configure command from the script and ran it manually. It worked once I removed the "-qt-sql-sqlite" switch.

                                  Now I'm ready to run make. If I run it from C:\Qt\Static\src\qt-everywhere-opensource-src-5.9.1, though, that's where it will install it. I want it in Qt\Static. Is there a switch I can use on the make command to tell it to put Qt in Qt\Static? (I know this isn't a Qt question, but it does pertain to building/installing Qt.)

                                  Thanks...

                                  kshegunovK 1 Reply Last reply
                                  0
                                  • mzimmersM mzimmers

                                    OK I copied the configure command from the script and ran it manually. It worked once I removed the "-qt-sql-sqlite" switch.

                                    Now I'm ready to run make. If I run it from C:\Qt\Static\src\qt-everywhere-opensource-src-5.9.1, though, that's where it will install it. I want it in Qt\Static. Is there a switch I can use on the make command to tell it to put Qt in Qt\Static? (I know this isn't a Qt question, but it does pertain to building/installing Qt.)

                                    Thanks...

                                    kshegunovK Offline
                                    kshegunovK Offline
                                    kshegunov
                                    Moderators
                                    wrote on last edited by kshegunov
                                    #17

                                    Rerun configure with -prefix /path/to/install and then you can proceed with building and installing.

                                    Read and abide by the Qt Code of Conduct

                                    1 Reply Last reply
                                    0
                                    • mzimmersM Offline
                                      mzimmersM Offline
                                      mzimmers
                                      wrote on last edited by
                                      #18

                                      OK, I did the configure, make and install. Seemed to work fine.

                                      I tried adding the new version of Qt in the build/run settings in Creator, but I get a warning "no qmlscene installed." A bit of googling reveals that this can be solved in the Linux world by installing qtdeclarative5-dev. Unfortunately, I can find no such analog for Windows.

                                      I also have a general message "Running Windows Runtime device detection. No winrtrunner.exe found." True enough, there's no such executable in my bin directory. Should I care about this?

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

                                        @mzimmers said in building a monolithic (standalone) program:

                                        No winrtrunner.exe found

                                        Mine also says that. If you are making a desktop app it should have no ill effects.

                                        1 Reply Last reply
                                        1
                                        • mzimmersM Offline
                                          mzimmersM Offline
                                          mzimmers
                                          wrote on last edited by
                                          #20

                                          OK, I think I got this working. To recap, the advice on this page is very good. There are a few tweaks to the PowerShell that are needed for smooth sailing, though:

                                          • the hard-coded default for the $QtSrcUrl variable is so old that it's not even on the download page anymore. Either pass it a different value using the "-QtSrcUrl" switch on the command line, or just edit it in the script.
                                          • IMPORTANT use the zip file, not the tarball, when downloading the source. The script assumes a .zip file and forms some variable names based on the filename. If you use the tarball, it will extract successfully, but the script will fail downstream.
                                          • the line:
                                          $GccList = @(Get-ChildItem -Path C:\Qt\*\Tools\mingw*\bin\gcc.exe | ForEach-Object FullName | Sort-Object)
                                          

                                          doesn't work, at least not on Windows 10. I had to remove the "\*" from the path.

                                          • in the invocation of configure.bat, I had to remove the "-qt-sql-sqlite" switch

                                          • also in the invocation of configure.bat, you might want to modify the "-prefix $QtDir " to point somewhere else, unless you want your static libraries under the src directory.

                                          Thanks again to everyone who helped with this.

                                          1 Reply Last reply
                                          3

                                          • Login

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