【问题标题】:How can I install Qt 5.2.1 from the command line in Cygwin?如何从 Cygwin 的命令行安装 Qt 5.2.1?
【发布时间】:2014-06-27 04:18:51
【问题描述】:
$ 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 环境编写构建脚本的优势在于,像 gitwgetscp 这样的命令 可用。这个Stackoverflow answer 描述了如何从 Cygwin bash 脚本调用 MSVC 编译器。请注意,我正在构建的 Qt 应用程序不会对 Cygwin 有任何依赖。

【问题讨论】:

  • 为 MSVC 编译的二进制文件与为 Cygwin 编译的二进制文件不兼容。也许你可以解释一下你真正想要完成的事情?
  • 您最好不要将 cygwin 与此混合。只需编写一个 bat 文件(如果您尝试做的事情是可能的)。
  • 我现在更新了这个问题。至于“社区”编辑,只是我忘记登录了。
  • 现在可能已经解决了。我还没有验证它,但在 Qt bug report 中写了这条评论:最新的在线安装程序和 5.5.0 离线安装程序提供了一种无人值守安装的方式。即使从普通终端。
  • @ErikSjölund 我也对该错误报告中的评论的含义感到困惑。这不是很有帮助,因为它仍然让我不知道如何真正实现自动化。你找到解决办法了吗?

标签: qt command-line installation cygwin


【解决方案1】:

我没有使用 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!通过添加标志 --verbose 并使用 UI 正常安装并在最后一页停止,我能够找到正确的 ID qt.55.win64_msvc2013_64;您选择安装的所有ids 都在那里。

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


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

gui.clickButton(buttons.NextButton, 3000);

编辑 (10-11-2019):请参阅 Joshua Wade's answer 了解更多陷阱和陷阱,例如“用户数据收集”表单以及“存档”和“最新版本”复选框。

【讨论】:

猜你喜欢
  • 2012-03-04
  • 2015-09-25
  • 1970-01-01
  • 2016-12-05
  • 2019-05-10
  • 1970-01-01
  • 2016-08-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多