- 浏览: 852268 次
- 性别:
- 来自: lanzhou
文章分类
最新评论
-
liu346435400:
楼主讲了实话啊,中国程序员的现状,也是只见中国程序员拼死拼活的 ...
中国的程序员为什么这么辛苦 -
qw8226718:
国内ASP.NET下功能比较完善,优化比较好的Spacebui ...
国内外开源sns源码大全 -
dotjar:
敢问兰州的大哥,Prism 现在在12.04LTS上可用么?我 ...
最佳 Ubuntu 下 WebQQ 聊天体验 -
coralsea:
兄弟,卫星通信不是这么简单的,单向接收卫星广播信号不需要太大的 ...
Google 上网 -
txin0814:
我成功安装chrome frame后 在IE地址栏前加上cf: ...
IE中使用Google Chrome Frame运行HTML 5
MacRuby 0.5b1 and can be downloaded from here. The beta can only be used on Snow Leopard, which means its Intel-only. They switched from using YARV as the internal engine to using LLVM. The major side effect of this change is that Ruby code can now be compiled.
Compilation is still pretty rough though. Many simple programs won't work, so at this point it's more of an example then a useful tool.
In order to get MacRuby to compile code, you need to have LLVM installed. It doesn't come as part of the MacRuby 0.5b1 download. I found directions at the Hatena::Diary blog. They're in Japanese. I don't speak the language and Google Translate butchers it, so I'm recreating it here with some additional notes.
The first thing to do is to download and install MacRuby. It's a zip file containing an OS/X install package. The package installs the MacRuby binaries to /usr/local/bin. Make sure it's in your PATH. All of the usual Ruby suspects are here, prefaced with 'mac'. So you have 'macruby', 'macgem', 'macirb', etc.
After you install it, you can run pretty much any Ruby program with macruby. This is still very much a work in progress, so don't be surprised when a program doesn't run or doesn't run correctly.
You use the 'macrubyc' command to compile code. But if you try to run it now, you'll get an error saying that it can't find 'llc'. That's because you don't have LLVM installed. And you need a very current copy.
Here's where Hatena's directions come into play.
$ svn co -r 82747 https://llvm.org/svn/llvm-project/llvm/trunk llvm-trunk $ cd llvm-trunk $ ./configure --prefix ~/opt $ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make -j2 $ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install
The 'svn' command will checkout revision 82747 of LLVM into the directory 'llvm-trunk'. Make sure you're in the directory you want the source checked out into when you run it.
The next two commands go down into the source code directory and set it up to install in an 'opt' directory under your home, e.g., '/Users/ctwise/opt'. This keeps the LLVM install local and won't conflict with any later system-wide installs. If you want LLVM installed to the same location as macruby then use the command './configure --prefix /usr/local'.
The fourth command compiles LLVM. It's setup to run two compiles simultaneously. If you're using a tool that monitors CPU load, you'll see both CPUs pegged. This compile step takes a long time.
The last command installs LLVM into the location you specified. If you want LLVM installed to '/usr/local', then you'll need to change the install command slightly to use sudo.
$ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install
Once you add '~/opt/bin' to your PATH, you can start compiling Ruby.
This small test program compiles and runs fine.
puts "Hello, World!" 'abc'.each_char do |str| puts str.upcase end
When run with 'macruby', it produces this output:
$ macruby test.rb
Hello, World!
A
B
C
To compile the program you use 'macrubyc'.
$ macrubyc -o test test.rb
This will create an executable named 'test' as well as a 'test.o' object file.
-rwxr-xr-x 1 ctwise staff 14784568 Oct 8 09:28 test* -rw-r--r-- 1 ctwise staff 2408 Oct 8 09:28 test.o -rw-r--r-- 1 ctwise staff 69 Oct 8 09:27 test.rb
If you want, you can use the 'file' command to see what the files are.
$ file test* test: Mach-O 64-bit executable x86_64 test.o: Mach-O 64-bit object x86_64 test.rb: ASCII text $ ./test Hello, World! A B C
And when you run 'test', you'll see the same output as running 'macruby test.rb'.
When I tried slightly more complex projects using gems, the compile went through cleanly but the resulting executable exited with an error code. YMMV.
The help file for 'macrubyc' states that it supports 'normal' and 'full' compilation. But setting it to 'full' gives you a message that 'full' mode isn't supported yet. A more interesting option is the '-V' or '--verbose' option. This will show you the actual commands being run to compile the code.
发表评论
-
Ruby 1.8 and 1.9 living in harmony
2010-02-22 07:54 890I’m running on OSX, and using M ... -
Metaprogramming in Ruby: It’s All About the Self
2009-11-16 11:28 913After writing my last post on R ... -
Perl vs. Python vs. Ruby
2009-11-07 21:05 1160I’m evaluating Python and Rub ... -
A Teenage Boy Improved Ruby 1.9 Performance Up to 63%
2009-11-06 18:26 909Japanese online magazine, @IT J ... -
Ruby Best Practices - The Complete Class
2009-11-04 16:21 1050A remark: we enabled comment mo ... -
调查显示Ruby北美地区用户量上升
2009-10-30 07:38 587据Evans Data最近针对400名开发用户的调查表明,R ... -
RubyForge将停止工作,RubyGems.org接替Gem hosting服务
2009-10-28 14:14 1850Ruby Gem维护者请注意,数周前,GitHubGitHub ... -
有关Ruby企业版1.8.7的一些介绍
2009-10-18 08:54 1310前几周,Ruby企业版(Rub ... -
3 Ruby Quirks You Have to Love
2009-10-16 10:50 661Ruby’s a fantastic language; we ... -
Distilling JRuby: The JIT Compiler
2009-10-09 08:40 1147The JIT compiler in JRuby is a ... -
10月编程语言排行榜:Ruby稳步提升
2009-10-08 08:07 1015新闻来源:51CTO.COMTIOBE今日公布了2009年10 ... -
为你的.NET应用程序添加一个REPL控制台
2009-10-07 12:45 791微软开始推广IronPython和IronRuby,希望它们可 ... -
Installing Ruby 1.8 and 1.9 on Ubuntu from Source
2009-10-05 14:18 923$ sudo apt-get build-dep ru ... -
Compiling Ruby 1.9.1 (stable) on Ubuntu
2009-10-05 14:13 765I found the default ruby inst ... -
JRuby综述:1.4的新特性、JRubyConf议程及MLVM
2009-10-02 08:25 892JRuby 1.4 RC1即将发布,我们来看看新版本都有哪些新 ... -
Ruby Enterprise Edition 1.8.7-20090928 released
2009-09-30 08:09 1184In the not so distant past we l ... -
Ruby DCamp,低迷经济下别开生面的会议
2009-09-22 08:47 1002经济的低迷不仅影响了 ... -
Ruby静态分析工具检视:metric_fu, Simian, Saikuro以及其他
2009-09-17 08:59 1497代码质量构成了软件质 ... -
Ruby 1.9.1程序库兼容性纵览
2009-09-15 09:38 1150ruby.1.9.1是1.9.x系列第一 ... -
ruby 1.9 真有这么快吗?
2009-09-14 18:26 1198早在今年2月份,Antonio Cangiano 发表过一份关 ...
相关推荐
《使用延续的编译》这本书是由普林斯顿大学计算机科学系的Andrew W. Appel所著,并于1992年由剑桥大学出版社出版。本书深入探讨了延续传递风格(Continuation-passing style, 简称CPS)在编译过程中的应用及其相关...
Aho and Ullman - The Theory of Parsing, Translation, and Compiling - Vol. 1 (1972).djvu Aho and Ullman - The Theory of Parsing, Translation, and Compiling - Vol. 2 (1973).djvu
VS6.0 安装及运行解决 Compiling... error spawning cl.exe 问题 本文将详细介绍 VS6.0 的安装与运行过程,并解决 Compiling... error spawning cl.exe 问题,以便帮助初学者更好地理解和应用 VS6.0。 路径的概念 ...
Advanced C and C++ Compiling 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者...
### "Compiling..., Error spawning cl.exe" 错误解析与解决方案 #### 一、问题概述 在使用Visual C++ 6.0进行编程时,不少用户可能会遇到一个常见的错误:“Compiling..., Error spawning cl.exe”。当尝试编译或...
### 高级C和C++编译技术概览 #### 引言 本书《高级C和C++编译》深入探讨了C与C++语言在现代操作系统环境下的编译技术,旨在帮助读者深入了解这两个广泛使用的编程语言在多任务操作系统中的工作原理及优化技巧。...
在Android应用开发的世界里,有时候我们可能需要对APK文件进行反编译,以便查看其源代码、资源文件或理解应用程序的工作原理。这通常用于学习、调试或逆向工程目的。在这一过程中,有几款关键的工具是必不可少的,...
### 关于跨平台工具链与CMake构建的相关知识点 #### 跨平台工具链(Cross-Toolchain) 跨平台工具链是指用于编译针对不同架构或操作系统的代码的工具集。通常,开发人员需要为不同的目标平台创建可执行文件,这时...
C++编译过程详解 C++编程语言的编译过程是一项复杂的系统工程,涉及多个阶段,从源代码到可执行程序的转化过程中,编译器起着至关重要的作用。本资料详细介绍了C++的编译过程,包括预处理、编译、汇编和链接四个...
本书《Advanced C and C++ Compiling.pdf》是一本深入探讨C与C++编程语言编译技术和实践的专业书籍。通过本书的学习,读者可以深入了解如何高效地利用这两种语言进行程序设计与优化。 #### 作者简介 该书由一位具有...
标题中的"TC.zip_Compiling"暗示了这是一个与C++编译相关的压缩包,可能包含一个C++编译器或者是一些编译C++程序所需的工具和资源。描述明确指出是"C++ Compiler for compiling c++ program",意味着这个压缩包的...
This book focuses on pure Python whenever possible to minimize compiling platform-dependent binaries, so that you don't become bogged down in just getting ready to do analysis., 'Learning Geospatial ...
Hot Reload Edit Code Without Compiling v1.12.5
PyBuilder是在Windows上用于将python脚本编译为exe格式的构建工具。 它具有易于使用的界面,并使用py2exe进行编译。 不再需要弄乱命令提示符或安装脚本。 PyBuilder会为您完成。
Fixed : Issue compiling demo's in trial version Fixed : Issue with LoadFromFile column widths in TTMSFMXGrid v2.1.0.2 Improved : GetTextHeight function in TTMSFMXHTMLText Fixed : Issue with iOS ...
主要特点 编辑任何功能 - 如果您有 C# 代码,热重载可以立即修补它。适用于任何文本编辑器。 轻松设置 - 导入并运行。无需更改项目或代码。 无缝 - 无需重新加载域即可应用更改。这意味着游戏会继续运行,所有...
《编译原理》是计算机科学领域的一门基础课程,它主要研究如何将高级程序设计语言转换为机器可执行的指令。这门课程对于理解计算机系统的内部运作至关重要,尤其对于那些致力于软件开发、系统编程或者想要深入研究...