ruby 怎么编译成可执行文件

Python011

ruby 怎么编译成可执行文件,第1张

你指的是在Windows平台吧。

编译成机器码的话就没遇到什么方案可用,但是打包成exe倒是有不少方案。

目前比较易用的是ocra:https://github.com/larsch/ocra

先安装:gem install ocra

然后:ocra script.rb 就能生成script.exe了

make[2]: Leaving directory `/data/apps/sa_gitlab/temp/ruby-1.9.3-p392/ext/objspace'

make[2]: Entering directory `/data/apps/sa_gitlab/temp/ruby-1.9.3-p392/ext/openssl'

compiling ossl_pkey_ec.c

ossl_pkey_ec.c: 在函数‘ossl_ec_group_initialize’中:

ossl_pkey_ec.c:761: 警告:隐式声明函数‘EC_GF2m_simple_method’

ossl_pkey_ec.c:761: 警告:赋值时将整数赋给指针,未作类型转换

ossl_pkey_ec.c:816: 错误:‘EC_GROUP_new_curve_GF2m’未声明(在此函数内第一次使用)

ossl_pkey_ec.c:816: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其

ossl_pkey_ec.c:816: 错误:所在的函数内也只报告一次。)

make[2]: *** [ossl_pkey_ec.o] 错误 1

make[2]: Leaving directory `/data/apps/sa_gitlab/temp/ruby-1.9.3-p392/ext/openssl'

make[1]: *** [ext/openssl/all] 错误 2

make[1]: Leaving directory `/data/apps/sa_gitlab/temp/ruby-1.9.3-p392'

make: *** [build-ext] 错误 2

1、执行ruby -v确定版本

2、执行whereis ruby找到ruby安装的位置。可能有多个位置。将每一个path的ruby都执行一下-v。比如 /usr/bin/ruby -v。看下哪个是你安装的1.9.3版本。假如就是/usr/bin/ruby

3、编辑/etc/profile,在最末尾添加一行:export PATH=/usr/bin/ruby:$PATH

4、执行source /etc/profile。然后再执行下ruby -v试下