如何让Qt4在Windows 7上运行ruby 1.9.2 ?

时间:2022-05-10 20:51:52

Summary

I'm writing a Ruby 1.9.2 app using Qt4 for its GUI which I want to distribute on Linux, OS X and Windows. I have the app running fine on everything except my Windows 7 64-bit box.

我正在为它的GUI编写一个使用Qt4的Ruby 1.9.2应用程序,我想在Linux、OS X和Windows上发布它。除了Windows 7 64位框外,我的应用程序运行良好。

There are working examples of Win7 + Qt4 + 1.8.7, but apparently not Win7 + Qt4 + 1.9.2. There are two gems for Ruby-Qt bindings, qtbindings and qtruby4 (sometimes referred to as qt4-qtruby), but I have not yet seen either of them running on Win7 with Ruby 1.9.2.

有Win7 + Qt4 + 1.8.7的工作示例,但显然不是Win7 + Qt4 + 1.9.2。Ruby- qt绑定有两个gem, qtbindings和qtruby4(有时称为qt4-qtruby),但是我还没有看到它们在Win7上运行,使用Ruby 1.9.2。

The Problem With qtruby4

This article from October 2008 and its updated version from June 2011 served as good starting points, but I differed from the latter by installing Ruby 1.9.2 via RubyInstaller for Windows' download page. 1.8.7 seemed to work fine, but I get some unusual errors when I try it with 1.9.2. Requiring 'rubygems' and then requiring 'Qt' results in:

这篇文章从2008年10月开始,从2011年6月开始更新,这是一个很好的起点,但是我和后者的不同之处在于,它通过RubyInstaller为Windows的下载页面安装了Ruby 1.9.2。1.8.7似乎运行得很好,但是当我尝试使用1.9.2时,我发现了一些不寻常的错误。要求“rubygems (rubygems)”,然后要求“Qt”,结果是:

no such file to load -- 'qtruby4'

The first article from above links to a more in-depth article from dr1ku which may provide some clues.

第一篇文章从上面链接到一个更深入的文章,从dr1ku可以提供一些线索。

  • It might be worth reproducing dr1ku's steps with the latest versions of these libraries.
  • 使用这些库的最新版本复制dr1ku的步骤可能是值得的。
  • dr1ku and the 2008 paschenda.org article both use a special Windows Qt4-QtRuby installer, but the maintainer notes that he hasn't had the time to update it. I'm not completely clear on what the special installer does, but I suppose paschenda.org's 2011 article no longer uses it because DevKit ostensibly helps RubyGems itself build Qt4 without assistance.
  • dr1ku和2008 paschenda.org的文章都使用了一个特殊的Windows Qt4-QtRuby安装程序,但是维护者注意到他没有时间更新它。我还不清楚这个特殊的安装程序会做什么,但是我想paschenda.org的2011年的文章不再使用它,因为DevKit似乎帮助RubyGems自己构建Qt4,而不需要帮助。

Found in the Wild

Here are some people who appear to be have encountered the same problem:

以下是一些似乎遇到了同样问题的人:

The Problem With qtbindings

My app actually uses the qtbindings gem, so I tried installing that instead, with gem install qtbindings --platform=mswin32.[1] However, when I tried to require 'Qt' with the qtbindings gem installed, I got a Windows popup with the following message:

我的应用程序实际上使用了qtbindings gem,因此我尝试安装它,使用gem安装qtbindings——platform=mswin32。但是,当我试图安装qtbindings gem时,需要'Qt'时,会弹出一个窗口,其中包含以下消息:

The procedure entry point _Z10qvsnprintfPcjPKcS_ could not be located in the dynamic link library QtCore4.dll. Just give up, inferior flesh creature.

程序入口点_Z10qvsnprintfPcjPKcS_不能位于动态链接库QtCore4.dll中。放弃吧,下等生物。

(I have copy and pasted the message without any embellishment whatsoever.)

(我复制粘贴了这条消息,没有任何修饰。)

Found in the Wild

Here are some people who appear to be have encountered the same problem:

以下是一些似乎遇到了同样问题的人:

Potential Success Stories

Someone out there seems to have had success by installing the qtbindings gem on 1.9.2 with gem install qtbindings (no --platform argument), if you look at the replies to this thread:

在1.9.2安装了qtbindings gem(没有——平台参数)的情况下,似乎有人已经取得了成功,如果您查看对这个线程的答复:

I tried installing with gem install qtbindings on 1.8.7, but I have not tried it with 1.9.2 yet. When I tried it with 1.8.7, I ran into the same "procedure entry point could not be located" issue as before.

我尝试在1.8.7上安装gem安装qtbindings,但是我还没有尝试过1.9.2。当我尝试使用1.8.7时,我遇到了和以前一样的“无法定位过程入口点”问题。

Footnotes

[1] - I'm actually not completely clear on the difference between the qtbindings gem and the qtruby4 gem. For example, does the latter include the C extension and the former does not? I'm not sure. Additionally, I have seen references to qt4-qtruby, which I think is just the mswin32 version of qtruby4, at least as far as I can tell from the Korundum download page.

[1] -我实际上不完全清楚qtbindings gem和qtruby4 gem之间的区别。例如,后者是否包含C扩展,而前者不包含?我不确定。此外,我还看到了qt4-qtruby的引用,我认为这只是qtruby4的mswin32版本,至少从Korundum下载页面可以看出是这样的。

1 个解决方案

#1


37  

The Solution

The following steps work on Windows 7:

Windows 7的工作步骤如下:

  1. Install Ruby 1.9.2 via the official download page.
  2. 通过官方下载页面安装Ruby 1.9.2。
  3. In a Windows shell, run gem install qtbindings.
  4. 在Windows shell中,运行gem安装qtbindings。

The trivial example (require 'rubygems'; require 'Qt') should now work.

简单的例子(需要“rubygems”;要求“Qt”)现在应该工作。

No extra steps are required because a binary gem is provided just for the Windows platform. The gem install qtbindings step will therefore take a few minutes as it downloads the large binary, but it contains all of the requisite parts to require and run Qt apps.

不需要额外的步骤,因为仅为Windows平台提供了二进制gem。gem安装qtbindings步骤因此在下载大型二进制文件时需要几分钟,但它包含需要和运行Qt应用程序的所有必要部分。

Compiling from source on Windows is supported, and documented in the project's README file.

支持从Windows上的源代码进行编译,并在项目的README文件中进行文档记录。

The Low-Down

I e-mailed the maintainers of qtbindings and qtruby. Here's the full story:

我给qtbindings和qtruby的维护者发了电子邮件。这是完整的故事:

qtruby is a package provided by the Korundum project. Korundum provides Ruby bindings to all of KDE, whereas qtruby provides bindings for only Qt.

qtruby是Korundum项目提供的软件包。Korundum为所有KDE提供了Ruby绑定,而qtruby只为Qt提供绑定。

qtbindings (github) is a modified and repackaged version of qtruby specifically optimized for cross-platform usage. I shall copy and paste the "Goals" section from its README here:

qtbindings (github)是qtruby的修改和重新打包版本,专门针对跨平台使用进行优化。我将复制并粘贴“目标”一节的自述:

Goals

  1. To make it easy to install a Qt binding for Ruby on all platforms using RubyGems
  2. 为了方便使用RubyGems在所有平台上为Ruby安装Qt绑定
  3. To maintain an up-to-date binary gem for Windows that is bundled with the latest version of Qt from http://qt.nokia.com
  4. 要为Windows维护一个最新的二进制gem,它与http://qt.nokia.com最新版本的Qt绑定在一起
  5. To reduce the scope and maintenance of the bindings to only bind to the libraries provided by the Qt SDK.
  6. 减少绑定的范围和维护,只绑定到Qt SDK提供的库。
  7. To increase compatibility with non-linux platforms
  8. 增加与非linux平台的兼容性

Though the Korundum downloads page does provide mswin32 versions of its gem, as of this writing they are not actively vetted by anyone, and so should not be relied upon. The QtRuby maintainer informed me that the RubyForge page will probably not be reliable until after QtRuby 3 is released.

尽管Korundum下载页面确实提供了mswin32版本的gem,但是在本文中,它们并没有受到任何人的主动审查,因此不应该依赖于它们。QtRuby维护者告诉我,在QtRuby 3发布之前,RubyForge页面可能不会是可靠的。

The Recap

Right now (10/3/2011), don't use the qtruby gem on Windows. Use qtbindings.

现在(10/3/2011),不要在Windows上使用qtruby gem。使用qtbindings。

You might be able to use qtruby on other platforms and qtbindings on Windows, but you'll probably be asking for trouble. If you are just going for Qt and don't care about the rest of KDE, qtbindings is probably a safe bet.

您可能可以在其他平台上使用qtruby,在Windows上使用qtbindings,但您可能会遇到麻烦。如果您只使用Qt,而不关心KDE的其余部分,那么qtbindings可能是安全的。

The maintainers of QtRuby are planning some methodology updates in the near future (such as using git), so there may be increased shared fixes and updates between the two projects.

QtRuby的维护者计划在不久的将来进行一些方法更新(例如使用git),因此两个项目之间可能会增加共享修复和更新。

#1


37  

The Solution

The following steps work on Windows 7:

Windows 7的工作步骤如下:

  1. Install Ruby 1.9.2 via the official download page.
  2. 通过官方下载页面安装Ruby 1.9.2。
  3. In a Windows shell, run gem install qtbindings.
  4. 在Windows shell中,运行gem安装qtbindings。

The trivial example (require 'rubygems'; require 'Qt') should now work.

简单的例子(需要“rubygems”;要求“Qt”)现在应该工作。

No extra steps are required because a binary gem is provided just for the Windows platform. The gem install qtbindings step will therefore take a few minutes as it downloads the large binary, but it contains all of the requisite parts to require and run Qt apps.

不需要额外的步骤,因为仅为Windows平台提供了二进制gem。gem安装qtbindings步骤因此在下载大型二进制文件时需要几分钟,但它包含需要和运行Qt应用程序的所有必要部分。

Compiling from source on Windows is supported, and documented in the project's README file.

支持从Windows上的源代码进行编译,并在项目的README文件中进行文档记录。

The Low-Down

I e-mailed the maintainers of qtbindings and qtruby. Here's the full story:

我给qtbindings和qtruby的维护者发了电子邮件。这是完整的故事:

qtruby is a package provided by the Korundum project. Korundum provides Ruby bindings to all of KDE, whereas qtruby provides bindings for only Qt.

qtruby是Korundum项目提供的软件包。Korundum为所有KDE提供了Ruby绑定,而qtruby只为Qt提供绑定。

qtbindings (github) is a modified and repackaged version of qtruby specifically optimized for cross-platform usage. I shall copy and paste the "Goals" section from its README here:

qtbindings (github)是qtruby的修改和重新打包版本,专门针对跨平台使用进行优化。我将复制并粘贴“目标”一节的自述:

Goals

  1. To make it easy to install a Qt binding for Ruby on all platforms using RubyGems
  2. 为了方便使用RubyGems在所有平台上为Ruby安装Qt绑定
  3. To maintain an up-to-date binary gem for Windows that is bundled with the latest version of Qt from http://qt.nokia.com
  4. 要为Windows维护一个最新的二进制gem,它与http://qt.nokia.com最新版本的Qt绑定在一起
  5. To reduce the scope and maintenance of the bindings to only bind to the libraries provided by the Qt SDK.
  6. 减少绑定的范围和维护,只绑定到Qt SDK提供的库。
  7. To increase compatibility with non-linux platforms
  8. 增加与非linux平台的兼容性

Though the Korundum downloads page does provide mswin32 versions of its gem, as of this writing they are not actively vetted by anyone, and so should not be relied upon. The QtRuby maintainer informed me that the RubyForge page will probably not be reliable until after QtRuby 3 is released.

尽管Korundum下载页面确实提供了mswin32版本的gem,但是在本文中,它们并没有受到任何人的主动审查,因此不应该依赖于它们。QtRuby维护者告诉我,在QtRuby 3发布之前,RubyForge页面可能不会是可靠的。

The Recap

Right now (10/3/2011), don't use the qtruby gem on Windows. Use qtbindings.

现在(10/3/2011),不要在Windows上使用qtruby gem。使用qtbindings。

You might be able to use qtruby on other platforms and qtbindings on Windows, but you'll probably be asking for trouble. If you are just going for Qt and don't care about the rest of KDE, qtbindings is probably a safe bet.

您可能可以在其他平台上使用qtruby,在Windows上使用qtbindings,但您可能会遇到麻烦。如果您只使用Qt,而不关心KDE的其余部分,那么qtbindings可能是安全的。

The maintainers of QtRuby are planning some methodology updates in the near future (such as using git), so there may be increased shared fixes and updates between the two projects.

QtRuby的维护者计划在不久的将来进行一些方法更新(例如使用git),因此两个项目之间可能会增加共享修复和更新。