【问题标题】:Creating Windows executable for ruby APP为 ruby​​ APP 创建 Windows 可执行文件
【发布时间】:2017-02-28 15:32:51
【问题描述】:

我在 Windows 上编写了一个小脚本项目,我的 gem 文件中有三个 gem

我在 ubuntu 上使用 Traveling ruby​​ 来创建它的包,但是在 rake 任务中,当脚本尝试下载 gem 时,这三个 gem 会出错,因为我认为它的窗口特定 gem 并寻找一些依赖项

我将这些 gem 保存在项目中并在 gem 文件中引用,该脚本很好地创建了 zip 文件,但是当我在 Windows 上运行它时,win32... gems not found 的错误

    rake package:win32 outputs when it try to fetch gems 

```shell
Fetching gem metadata from http://rubygems.org/............
Fetching version metadata from http://rubygems.org/.
Resolving dependencies...
Using jmespath 1.3.1
Using ffi 1.9.14
Using mini_magick 4.3.6
Installing win32-api 1.4.8 (was 1.6.0) with native extensions
Using bundler 1.13.5
Using aws-sdk-core 2.6.10
Using rautomation 0.17.0
Using win32-clipboard 0.6.4
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/vishalgarg/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20161019-3963-1e9bkxl.rb extconf.rb
checking for strncpy_s()... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling win32/api.c
win32/api.c:2:21: fatal error: windows.h: No such file or directory
 #include <windows.h>
                     ^
compilation terminated.
make: *** [api.o] Error 1

make failed, exit code 2


```

【问题讨论】:

    标签: ruby rubygems rake


    【解决方案1】:

    所以最后我得到了答案,所以旅行红宝石对我不起作用,因为它的一些限制

    因此,与 Ocra Gem 一起使用是件好事 (https://github.com/larsch/ocra)

    在 windows 上简单安装 gem(我在 windows 上制作了应用程序) 并运行命令

    ocra <Ruby file name > --verbose --gem-full --no-dep-run --add-all-core --gemfile Gemfile
    

    它将生成 exe 文件,您可以在任何窗口上运行它

    【讨论】:

    • 如果您对如何使用 ruby​​ 构建桌面应用程序知之甚少,将会很有帮助
    猜你喜欢
    • 1970-01-01
    • 2016-11-14
    • 2021-03-11
    • 2011-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多