Ubuntu Ruby
2016-09-21 本文已影响0人
MrKitty
Ruby是全球流行的编程语言,...。
Ubuntu 14.04
apt-get install ruby
默认安装的是 Ruby 1.9.1
然后开始下载、解压
Ruby,
- 下载:
sudo wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.3.tar.gz
- 解压:
sudo tar xvzf ruby-2.1.3.tar.gz
开始安装Ruby
sudo ./configure --prefix=/usr/local/env/ruby
sudo make
sudo make test
sudo make install
分析并解决在安装Ruby过程中提示的错误信息
make test
结果
Failed to configure -test-/win32/dln. It will not be installed.
Failed to configure -test-/win32/fd_setsize. It will not be installed.
Failed to configure dbm. It will not be installed.
Failed to configure fiddle. It will not be installed.
Failed to configure gdbm. It will not be installed.
Failed to configure openssl. It will not be installed.
Failed to configure readline. It will not be installed.
Failed to configure tk. It will not be installed.
Failed to configure tk/tkutil. It will not be installed.
Failed to configure win32. It will not be installed.
Failed to configure win32ole. It will not be installed.
Failed to configure zlib. It will not be installed.
make
结果,分析这些错误信息所需安装的软件,与Ubuntu等linux服务器系统平台有关是:
- dbm
- fiddle :libffi
- gdbm :gdbm 是 dbm 的升级版本,只需要安装 gdbm 即可
- openssl
- readline :依赖关系 readline > libedit > ncurses( for: libcurses or libncurses )
- ripper :依赖关系 ripper > bison > m4
- zlib
configuring dbm
Failed to configure dbm. It will not be installed.
...
configuring fiddle
ffi.h is missing. Please install libffi.
Failed to configure fiddle. It will not be installed.
...
Failed to configure gdbm. It will not be installed.
...
Failed to configure openssl. It will not be installed.
...
configuring readline
readline nor libedit not found
Failed to configure readline. It will not be installed.
...
configuring ripper
missing bison; abort
Failed to configure ripper. It will not be installed.
...
Failed to configure zlib. It will not be installed.
wget ftp://ftp.gnu.org/gnu/gdbm/gdbm-1.11.tar.gz & cd gdbm-1.11 & sudo ./configure && make && make install
2、fiddle ( libffi )
sudo wget ftp://sourceware.org/pub/libffi/libffi-3.1.tar.gz && sudo tar xvzf libffi-3.1.tar.gz && cd libffi-3.1 && sudo ./configure && sudo make && sudo make install
.h 在/usr/local/lib/libffi-3.1/include,不是在/usr/local/include,需要手动指定,明显文件逻辑不正确
cd ../libffi-3.1 && sudo ./configure --help
sudo ./configure --prefix=/usr/local/env/libffi --includedir=/usr/local/env/libffi/include # 无效
依旧保留文件版本目录 /usr/local/env/libffi/include/libffi-3.1/include
3、openssl
彻底删除 openssl
sudo apt-get purge openssl && sudo apt-get autoremove && apt-get autoclean
http://askubuntu.com/questions/429385/upgrade-openssl-on-ubuntu-12-04
sudo ./config --prefix=/usr/local/env/openssl shared && sudo make && sudo make install
shared 共享问题:shared 参数解决如下错误信息:
/usr/bin/ld: /usr/local/env/openssl/lib/libcrypto.a(md5_dgst.o): relocation R_X86_64_PC32 against undefined symbol `memcpy@@GLIBC_2.14' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [../../../.ext/x86_64-linux/digest/md5.so] Error 1
make[2]: Leaving directory `/usr/local/src/ruby-2.1.2/ext/digest/md5'
make[1]: *** [ext/digest/md5/all] Error 2
make[1]: Leaving directory `/usr/local/src/ruby-2.1.2'
make: *** [build-ext] Error 2
/usr/local/env/openssl/bin 添加到:/etc/environment
安装到系统默认的openssl,参数如下:
...
4、readline
sudo ./configure --prefix=/usr/local/env/readline && sudo make && sudo make install
sudo ./configure --prefix=/usr/local/env/libedit && sudo make && sudo make install
# 错误信息:configure: error: libcurses or libncurses are required!
sudo ./configure --with-shared && sudo make && sudo make install #ncurses
shared 共享错误信息:添加share参数
_nc_globals' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libcurses.a: error adding symbols: Bad value
5、Ripper
wget http://ftp.gnu.org/gnu/bison/bison-3.0.2.tar.gz
cd ../bison-3.0.2 && sudo ./configure && sudo make && sudo make install
sudo wget http://ftp.gnu.org/gnu/m4/m4-1.4.17.tar.gz && sudo tar xvzf m4-1.4.17.tar.gz && cd m4-1.4.17 && sudo ./configure && sudo make && sudo make install
6、zlib
...
安装Ruby:成功!
参考:http://mac-dev-env.patrickbougie.com/ruby-21/
由于libffi的include路径问题,以及openssl与readline使用非系统路径,需要手动指定这个3个的目录,使用参数--with-opt-dir
自动加载目录中的include与lib文件夹。以下是完整安装Ruby命令及参数:
sudo ./configure --prefix=/usr/local/env/ruby --with-opt-dir=/usr/local/lib/libffi-3.1:/usr/local/env/openssl:/usr/local/env/readline
sudo make && sudo make install
#sudo make 信息
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -ansi -std=iso9899:199409
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
CPPFLAGS = -I/usr/local/src/openssl-1.0.1i/include -I/usr/local/src/readline-6.3/include -I. -I.ext/include/x86_64-linux -I./include -I.
DLDFLAGS = -L/usr/local/src/openssl-1.0.1i/lib -Wl,-R/usr/local/src/openssl-1.0.1i/lib -L/usr/local/src/readline-6.3/lib -Wl,-R/usr/local/src/readline-6.3/lib -fstack-protector -pie
nano /etc/environment # 添加 /usr/local/env/ruby/bin