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

Eri*_*und 11 installation qt command-line 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
$
Run Code Online (Sandbox Code Playgroud)

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

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

首先,我在文件上设置了正确的权限

$ chmod 755 qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe
Run Code Online (Sandbox Code Playgroud)

如果我这样开始

$ ./qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe
Run Code Online (Sandbox Code Playgroud)

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

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

$ ./qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe --help
Run Code Online (Sandbox Code Playgroud)

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

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.
Run Code Online (Sandbox Code Playgroud)

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

更新:为Cygwin环境编写构建脚本的优点是可以使用git,wgetscp等命令.此Stackoverflow答案描述了如何从Cygwin bash脚本调用MSVC编译器.请注意,我正在构建的Qt应用程序不会对Cygwin有任何依赖性.

Nil*_*Nil 7

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

.\qt-opensource-windows-x86-msvc2013_64-5.5.1.exe --script .\qt-installer-noninteractive.qs
Run Code Online (Sandbox Code Playgroud)

这是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);
}
Run Code Online (Sandbox Code Playgroud)

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

如果您需要更多详细信息,请在此答案中提供更多信息.


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

gui.clickButton(buttons.NextButton, 3000);
Run Code Online (Sandbox Code Playgroud)

  • 看起来包名称与 Qt SDK 存储库中的名称匹配,请参见例如 https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5112/ (2认同)