月份: 2014-03

Ruby 环境搭建时 openssl.so LoadError 问题

在CentOS 下布署ROR环境时, gem update 指令报如下错误

/opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-linux/openssl.so: undefined symbol: EC_GROUP_new_curve_GF2m - /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-linux/openssl.so (LoadError)
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/openssl.rb:17:in `<top (required)>'
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

应该是 openssl 版本问题所致,解决方案如下:
Installing OpenSSL anywhere besides /usr puts the libraries in the expected lib instead of lib64. (Don’t ask me why… dunno.) This may be the more maintainable solution as it lets you avoid hacking up the Makefile. This is also the solution RVM uses when running rvm pkg install openssl. Thus, to install both OpenSSL and Ruby (in /opt), you may run commands something like these (I run as sudo bash):
Install OpenSSL:
cd /opt/local
wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz
tar -xzf openssl-1.0.1f.tar.gz
cd openssl-1.0.1f
./config --prefix=/opt/local shared no-asm zlib > openssl_config.log
make > openssl_make.log
make install > openssl_install.log

(The shared switch is required for Ruby to install without error, the no-asm switch helps get rid of a Make warning but does not appear to be required, and zlib and other switches are optional.)
Optional, update openssl certs:
cd /opt/local/ssl
wget http://curl.haxx.se/ca/cacert.pem
mv cacert.pem cert.pem
cd /opt

Back to Ruby: 连接指定的OpenSSL 安装
ruby-install ruby 1.9.3-p545 -- --with-openssl-dir=/opt/local
或者RVM环境下:
rvm install 1.9.3 --with-openssl-dir=/opt/local

问题解决, gem update 成功!

用 Jadclipse + jad 在 eclipse 环境下自动反编译查看class文件源码

一、安装插件Jadclipse
jadclips插件网站: http://jadclipse.sourceforge.net/
以下的链接中有 jad.exe 与 plugin.jar
jad&jadclipse plugin
二、安装:
将jadclipse_3.3.0.jar复制到%ECLIPSE_HOME%\plugins目录下。
三、设置参数:
启动eclipse,打开:Window->Preferences->Java->JadClipse.
1、Path to decompiler,设置反编译工具jad的全路径名,即如上包中的 jad.exe 的路径。
2、Directory for temporary files,这里设置临时文件路径。
四、安装完成后,eclipse自动将JadClipse Class File Viewer设置成class文件的缺省打开方式。如果没有默认,可以在Eclipse的Windows——> Perference——>General->Editors->File Associations中修改“*.class”默认关联的编辑器为“JadClipse Class File Viewer”。设置完成后,双击*.class文件,eclipse将自动反编译。
注: 对于存在源代码的类,它不会强行反编译,也就是说它还是会用eclipse自带的Class File Viewer查看class文件。