使用Ocra从Ruby文件制作可执行文件,LoadError吗? [英] Making an executable from ruby files using Ocra, LoadError?

查看:167
本文介绍了使用Ocra从Ruby文件制作可执行文件,LoadError吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从Windows上的几个ruby文件制作可执行文件,所以我安装了Ocra.我以为我了解Ocra的工作过程,但似乎无法使可执行文件正常工作.我遇到的问题是需要"其他红宝石文件.

I'm trying to make an executable from a couple ruby files on Windows, so I installed Ocra. I thought I understood the process of how Ocra works, but can't seem to get the executable working correctly. The problem I am having arises with "requiring" other ruby files.

ruby​​程序本身可以正确编译并按照我希望的方式运行,Ocra似乎创建了一个可运行的可执行文件,但是,当我尝试运行可执行文件时,出现以下错误:

The ruby program by itself compiles correctly and functions how I want it to, and Ocra seems to create a working executable, however, when I attempt to run the executable, I get the following error:

*/custom_require.rb:36:在'require'中:无法加载此类文件-MainMenuDialog.rb(LoadError)*

*/custom_require.rb:36:in 'require': cannot load such file -- MainMenuDialog.rb (LoadError)*

我的主程序称为'JobManager.rb',它正在创建一个新的MainMenuDialog对象,因此,我在文件顶部包含MainMenuDialog.rb,如下所示:

My main program is called 'JobManager.rb' and it is creating a new MainMenuDialog object, therefore I include MainMenuDialog.rb in the top of the file as such:

$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
# Other requires here
require("MainMenuDialog.rb")

同样,该程序单独编译并运行完美(包括require语句),当我运行命令 ocra JobManager.rb 时,它成功运行了程序,检查了依赖关系并创建了可执行文件.由于上述"LoadError",我无法运行可执行文件.

Again, the program compiles and runs perfectly fine by itself (including the require statements), and when I run the command ocra JobManager.rb it successfully runs the programs, checks for dependencies, and creates the executable. I just can't run the executable because of the "LoadError" described above.

对我在做什么错有任何想法吗?预先谢谢!!!

Any thoughts on what I'm doing wrong? Thanks in advance!!!

推荐答案

使用ruby> = 1.9,您可以尝试require_relative.

With ruby >= 1.9 you may try require_relative.

说明:ocra将所有文件存储在其自己的子目录中.

Explanation: ocra stores all files in its own subdirectories.

如果您操纵加载路径($ :),则无法确定ocra在执行过程中使用了什么.

If you manipulate the load pathes ($:) you can't be sure, what ocra uses during execution.

这篇关于使用Ocra从Ruby文件制作可执行文件,LoadError吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆