Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install Qt 5.2.1 from the command line in Cygwin?

$ 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.

like image 535
Erik Sjölund Avatar asked May 09 '14 12:05

Erik Sjölund


1 Answers

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.

like image 96
Nil Avatar answered Oct 18 '22 02:10

Nil