Fix Thrift 0.2.0 Installation with Ruby 1.9.1
When I try the command "gem install thrift" with Ruby 1.9.1, I got a compilation error with something related to a C function "strlcpy()".
Then I searched the web. It seems I am not alone and the community know it.
However I do not want to wait for official update, I want to try Cassandra and Thrift is a dependency I have to use now.
So, read on if you want a dirty fix.
Start command line console and run:
$ gem install thrift
If you got the error with "strlcpy", you should have thrift code downloaded in your ruby gems folder.
It is "C:\Ruby\lib\ruby\gems\1.9.1\gems\thrift-0.2.0" for my computer on Windows.
$ cd C:\Ruby\lib\ruby\gems\1.9.1\gems\thrift-0.2.0\ext
If you are using linux, check the lib/.../ext folder.
Open "extconf.rb" and "struct.c" with a text editor. Comment out HAVE_STRLCPY in "struct.c" like this:
/*
#ifndef HAVE_STRLCPY
static
size_t
strlcpy (char *dst, const char *src, size_t dst_sz)
{ ...
}
#endif
*/
Comment out have_func line in "extconf.rb" like this:
# have_func("strlcpy", "string.h")
Then run:
$ cd C:\Ruby\lib\ruby\gems\1.9.1\gems\thrift-0.2.0
$ ruby setup.rb
$ gem spec C:\Ruby\lib\ruby\gems\1.9.1\cache\thrift-0.2.0.gem --ruby > \
C:\Ruby\lib\ruby\gems\1.9.1\specifications\thrift-0.2.0.gemspec
$ gem list
You should see "thrift (0.2.0)" is in your local installed gem list.
相关文档:
class Tree
def initialize
puts "Make a normal tree"
end
def decorate
puts "Make sure the tree won\'t fall"
end
end
class RedBalls < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "Put on some red balls"
end
end
......
irb 是从命令行运行的
irb 的命令行选项(摘自 Porgramming Ruby 第二版)
-f
禁止读取~/.irbrc Suppress reading ~/.irbrc.
-m
数学模式(支持分数和矩阵) Math mode (fraction and matrix support is available).
-d
设置#DEBUG为true(同ruby -d一样) Set $DEBUG to true (same as ``ruby -d'').
-r lo ......
文章转自 http://www.ej38.com/showinfo/Ruby-140367.html
过程如下:
1、ruby下载一键安装:
http://rubyforge.org/frs/download.php/29263/ruby186-26.exe
ruby -v 显示版本,安装成功
2、下载rubygems安装:
http://rubyforge.org/frs/download.php/60719/rubygems-1.3.5.zip
解压,ruby setup.rb
g ......
操作系统ubuntu,开发工具netbeans
vendor数据库表有字段service_category varchar(100)
<% form_for :vendor, @vendor, :url => sellers_path do |f| %>
<%= f.select(:service_category,
  ......
#一、模块定义及引用,模块就是一段代码,里面有一些方法放一起。
#定义模块用module...end 。模块与类非常相似,但是:
#A) 模块不可以有实例对象;
#B) 模块不可以有子类。
include Math
puts sqrt(91);
module Me
def sqrt(a)
puts a*a;
return a*a;
end
PI=3.1415926 ......