如何从Cygwin的命令行安装Qt 5.2.1?

时间:2014-05-09 12:12:23

标签: qt command-line installation 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
$

如上所示,我首先在Cygwin Bash shell中下载了Visual Studio的Qt包。

旁注:Cygwin中打包的Qt库对我没用,因为我需要使用Visual Studio C ++编译器。

首先,我在文件

上设置了正确的权限
$ chmod 755 qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe

如果我这样开始

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

显示了一个图形窗口(GUI),但这不是我想要的,因为我后来希望将安装过程写入我可以在Cygwin中运行的Bash脚本。

如果我添加选项--help,就像这样

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

打开一个新的终端窗口,其中包含以下文本

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.

我不知道如何从这里继续。你知道如何从Cygwin的Bash shell安装Qt 5.2.1库(对于Visual Studio)吗?

更新:为Cygwin环境编写构建脚本的优势在于 git wget scp等命令可用。这个Stackoverflow answer描述了如何从Cygwin bash脚本调用MSVC编译器。请注意,我构建的Qt应用程序不会对Cygwin产生任何依赖。

1 个答案:

答案 0 :(得分:6)

我没有使用Cygwin测试,但我使用脚本成功安装了Qt5.5。为此,您必须使用普通安装程序的--script行。

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

这是我在上面的命令中使用的qt-installer-noninteractive.qs文件的示例

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);
}

棘手的部分是找到组件的id!通过添加标记qt.55.win64_msvc2013_64并使用UI正常安装并在最后一页停止,我能够找到正确的标识--verbose;您选择安装的所有ids都在那里。

如果您需要更多详细信息,请在此answer中提供更多信息。

编辑(29-11-2017):对于安装人员3.0.2-online,"下一步" "欢迎"中的按钮页面被禁用1秒,因此您必须添加延迟

gui.clickButton(buttons.NextButton, 3000);