building a monolithic (standalone) program
-
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...
-
@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. -
@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.
-
@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 :)
-
@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...
-
@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.)
-
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?
-
@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? -
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.
-
@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 domingw32-make
/nmake
to build. Although providing the dependencies for windows is pretty finicky in my experience. -
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...
-
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?
-
@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.
-
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.