12
$ wget --quiet http://download.qt-project.org/official_releases/qt/5.2/5.2.1/qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe
$

As seen above, I first downloaded the Qt package for Visual Studio in a Cygwin Bash shell.

A sidenote: The Qt library packaged within Cygwin is not useful for me because I need to use the Visual Studio C++ compiler.

First I set the correct permissions on the file

$ chmod 755 qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe

If I start it like this

$ ./qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe

a graphical window (GUI) is shown but that is not what I want as I would later like to have the installation procedure written into a Bash script that I could run in Cygwin.

If I add the option --help, like this

$ ./qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe --help

a new terminal window is opened with the following text

Usage: SDKMaintenanceTool [OPTIONS]

User:
  --help                                      Show commandline usage                  
  --version                                   Show current version                    
  --checkupdates                              Check for updates and return an XML file describing
                                              the available updates                   
  --updater                                   Start in updater mode.                  
  --manage-packages                           Start in packagemanager mode.  
  --proxy                                     Set system proxy on Win and Mac.        
                                              This option has no effect on Linux.     
  --verbose                                   Show debug output on the console        
  --create-offline-repository                 Offline installer only: Create a local repository inside the
                                              installation directory based on the offline
                                              installer's content.                    

Developer:
  --runoperation [OPERATION] [arguments...]   Perform an operation with a list of arguments
  --undooperation [OPERATION] [arguments...]  Undo an operation with a list of arguments
  --script [scriptName]                       Execute a script                        
  --no-force-installations                    Enable deselection of forced components 
  --addRepository [URI]                       Add a local or remote repo to the list of user defined repos.
  --addTempRepository [URI]                   Add a local or remote repo to the list of temporary available
                                              repos.                                  
  --setTempRepository [URI]                   Set a local or remote repo as tmp repo, it is the only one
                                              used during fetch.                      
                                              Note: URI must be prefixed with the protocol, i.e. file:///
                                              http:// or ftp://. It can consist of multiple
                                              addresses separated by comma only.      
  --show-virtual-components                   Show virtual components in package manager and updater
  --binarydatafile [binary_data_file]         Use the binary data of another installer or maintenance tool.
  --update-installerbase [new_installerbase]  Patch a full installer with a new installer base
  --dump-binary-data -i [PATH] -o [PATH]      Dumps the binary content into specified output path (offline
                                              installer only).                        
                                              Input path pointing to binary data file, if omitted
                                              the current application is used as input.

I don't know how to continue from here. Do you know how I could install the Qt 5.2.1 library (for Visual Studio) from the Bash shell in Cygwin?

Update: The advantage of writing the build script for a Cygwin environment is that commands like git, wget, and scp are available. This Stackoverflow answer describes how to invoke the MSVC compiler from a Cygwin bash script. Note, that the Qt application I'm building is not going to have any dependency on Cygwin.

Community
  • 1
  • 1
Erik Sjölund
  • 10,690
  • 7
  • 46
  • 74
  • Binaries compiled for MSVC are not compatible with those built for Cygwin. Perhaps you could explain what you're actually trying to accomplish? – Yaakov May 09 '14 at 19:34
  • You'd probably be better off not mixing cygwin to this. Just write a bat file (if what you try to do is possible). – hyde May 10 '14 at 06:49
  • I have now updated the question. As to the "Community" edit, it was just me forgetting to log in. – Erik Sjölund May 10 '14 at 07:41
  • Maybe it has been solved now. I haven't verified it but in a [Qt bug report](https://bugreports.qt.io/browse/QTBUG-40852?focusedCommentId=290923&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-290923) this comment was written: _The latest online installers and 5.5.0 offline installers provide a way for unattended installations. Even from plain terminal._ – Erik Sjölund Aug 26 '15 at 13:45
  • @ErikSjölund I'm also puzzled about how that comment in that bug report was meant. It's not very helpful because it still leaves me without a clue of how to actually automate this. Did you find a solution? – josch Mar 14 '16 at 13:32
  • @josch I haven't investigated it any further. So no I haven't found any solution yet. – Erik Sjölund Mar 14 '16 at 13:44

1 Answers1

8

I didn't test with Cygwin but I successfully installed Qt5.5 using a script. To do so, you must use the --script line of the normal installer.

.\qt-opensource-windows-x86-msvc2013_64-5.5.1.exe --script .\qt-installer-noninteractive.qs

Here's an example of qt-installer-noninteractive.qs file I used in the command above

function Controller() {
  installer.autoRejectMessageBoxes();
  installer.installationFinished.connect(function() {
    gui.clickButton(buttons.NextButton);
  })
}

Controller.prototype.WelcomePageCallback = function() {
  gui.clickButton(buttons.NextButton);
}

Controller.prototype.CredentialsPageCallback = function() {
  gui.clickButton(buttons.NextButton);
}

Controller.prototype.IntroductionPageCallback = function() {
  gui.clickButton(buttons.NextButton);
}

Controller.prototype.TargetDirectoryPageCallback = function() {
  gui.currentPageWidget().TargetDirectoryLineEdit.setText("C:/Qt/Qt5.5.1");
  gui.clickButton(buttons.NextButton);
}

Controller.prototype.ComponentSelectionPageCallback = function() {
  var widget = gui.currentPageWidget();

  widget.deselectAll();
  widget.selectComponent("qt.55.win64_msvc2013_64");
  // widget.selectComponent("qt.55.qt3d");
  // widget.selectComponent("qt.55.qtcanvas3d");
  // widget.selectComponent("qt.55.qtquick1");
  // widget.selectComponent("qt.55.qtscript");
  // widget.selectComponent("qt.55.qtwebengine");
  // widget.selectComponent("qt.55.qtquickcontrols");
  // widget.selectComponent("qt.55.qtlocation");

  gui.clickButton(buttons.NextButton);
}

Controller.prototype.LicenseAgreementPageCallback = function() {
  gui.currentPageWidget().AcceptLicenseRadioButton.setChecked(true);
  gui.clickButton(buttons.NextButton);
}

Controller.prototype.StartMenuDirectoryPageCallback = function() {
  gui.clickButton(buttons.NextButton);
}

Controller.prototype.ReadyForInstallationPageCallback = function()
{
  gui.clickButton(buttons.NextButton);
}

Controller.prototype.FinishedPageCallback = function() {
  var checkBoxForm = gui.currentPageWidget().LaunchQtCreatorCheckBoxForm
  if (checkBoxForm && checkBoxForm.launchQtCreatorCheckBox) {
    checkBoxForm.launchQtCreatorCheckBox.checked = false;
  }
  gui.clickButton(buttons.FinishButton);
}

The tricky part was to found the id of the components! I was able to found the right id qt.55.win64_msvc2013_64 by adding the flag --verbose and installing it normally with the UI and stopping at the last page; all the ids that you selected for installation are there.

There is slightly more information in this answer if you need more details.


EDIT (29-11-2017): For installer 3.0.2-online, the "Next" button in the "Welcome" page is disabled for 1 second so you must add a delay

gui.clickButton(buttons.NextButton, 3000);

EDIT (10-11-2019): See Joshua Wade's answer for more traps and pitfalls, like the "User Data Collection" form and "Archive" and "Latest releases" checkboxes.

Nil
  • 2,345
  • 1
  • 26
  • 33
  • I haven't tested the solution in this answer, but I mark it as the selected answer. – Erik Sjölund Apr 25 '17 at 06:06
  • 2
    Looks like package names match those in the Qt SDK repo, see e.g. https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5112/ – bleater Nov 01 '18 at 03:45