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.
相关文档:
在使用中ruby的过程中难免会遇到提高性能的问题,由此便想起了ruby线程。但是我在使用中却发现ruby的线程却不能提高性能。我写了以下代码,做了些简单测试。
代码
# -*- coding: GB2312 -*-
require 'date'
# 使用线程,线程的处理代码里没有sleep
def have_thread_no_sleep
p Time.now
thread1 = Thread.new do
......
1. ruby已成为1.87
2. 必须先安装安装光盘里的新的xcode,在"optional"目录里
3. 可能需要重新安装macport
http://trac.macports.org/wiki/Migration
4. 或者升级macport
http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard
$ sudo port selfupdate
$ sudo port sync
$ sudo port upgrade --force insta ......
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 ......
Beginning Ruby from Novice To Perfessional
Head First Rails
Agile Web Development with Rails 3rd Edition(new)
Agile Web Development with Rails 3rd Edition
Agile Web Development with Rails 3rd Editio ......