转自:http://appsintheopen.com/posts/18-installing-the-libv8-ruby-gem-on-centos-5-8

First, Centos 5.8 ships with gcc 4.1.4, but to compile libv8 you need 4.4. Luckily, this step is easy:

$ yum install gcc44-c++

Next, you need to tell the build to make use of it. The easiest thing to do here, is to export a couple of environment variables:

$ export CC=/usr/bin/gcc44
$ export CXX=/usr/bin/g++44

Now if you attempt gem install libv8, you will get an error along the lines of:

$ gem install libv8
creating MakefileUsing compiler:/usr/bin/g++44Traceback(most recent call last):File"build/gyp/gyp", line 15,in?import gyp
File"build/gyp/pylib/gyp/__init__.py", line 8,in?import gyp.input
File"build/gyp/pylib/gyp/input.py", line 14,in?import gyp.common
File"build/gyp/pylib/gyp/common.py", line 375with open(source_path)as source_file:^SyntaxError: invalid syntax
gmake:***[out/Makefile.x64]Error1
GYP_GENERATORS=make \
build/gyp/gyp --generator-output="out" build/all.gyp \
-Ibuild/standalone.gypi --depth=. \
-Dv8_target_arch=x64 \
-S.x64 -Dhost_arch=x64

This is because the version of Python that is shipped with Centos is too old. Upgrading Python is not too hard, but be warned - do not under any circumstance replace the shipped Centos Python - lots of stuff depends on it, and it you replace it, lots of stuff will break.

To install Python 2.7:

$ yum install bzip2
$ yum install bzip2-devel
$ wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
$ tar -xf Python-2.7.3.tgz
$ cd Python-2.7.3
$ ./configure
$ make
$ make altinstall

The final step is very important - this stops it overwriting the default Centos Python. We are on the home straight now. To get the libv8 install to use Python 2.7 instead of Python 2.4, I thought I could create a symlink in my local directory, and then slip my local directory onto the front of my path:

$ ln -s /usr/local/bin/python2.7 python
$ export PATH=.:$PATH
$ python --version
Python2.7.3

However, that didn't work.

I don't know why - maybe the Makefile explicitly references /usr/bin/python? What I did was move the existing Python executable out of the way, and symlink the Python 2.7 in its place:

$ mv /usr/bin/python /usr/bin/python_
$ ln -s /usr/local/bin/python2.7/usr/bin/python

Finally:

$ gem install libv8
( about 5 minutes later)Buildingnative extensions.This could take a while...Successfully installed libv8-3.11.8.41 gem installed
Installing ri documentation for libv8-3.11.8.4...InstallingRDoc documentation for libv8-3.11.8.4...

Now remember, to put Python back the way you found it:

$ rm /usr/bin/python
$ mv /usr/bin/python_ /usr/bin/python

Job done - finally.

【转】Installing the libv8 Ruby gem on Centos 5.8的更多相关文章

  1. Ruby Gem命令详解

    转自:http://www.jianshu.com/p/728184da1699 Gem介绍: Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.o ...

  2. Ruby Gem命令

    Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.org/ )源来查找.安装.升级和卸载软件包,非常的便捷. Ruby 1.9.2版本默认已安装Ru ...

  3. ruby gem tips(转)

    淘宝源: https://ruby.taobao.org 升级ruby gem gem update --system 查看gem版本 gem -v 查看gem版本,gems安装目录,remote s ...

  4. Installing MySQL 5.7.23 on CentOS 7

    Installing MySQL 5.7.23 on CentOS 7 1. 安装前检查 1.1 检查NUMA是否开启 NUMA为什么要咋MySQL中禁用? MySQL是单进程多线程架构数据库,当nu ...

  5. bundler简介(ruby gem)

    簡介 Bundler   RubyGem 是包裝.散佈Ruby程式庫的標準方式,相關文件可以參考 RubyGems Guides 的說明,或是 簡介 plugins 中的第二個例子.在使用rails ...

  6. ruby gem install rails 错误解决

    最近打算看ruby. 今天用命令gem install rails的时候碰到这样的错误提示: ERROR:  Error installing XXXXXXXXXXX:            The ...

  7. ruby(&gem) koala安装

    1.ruby下载安装 下载地址:http://railsinstaller.org/en 选择合适版本 2.gem(安装ruby时自带gem) 删除原镜像:gem sources --remove h ...

  8. 转 关于ruby gem无法连接到rubygems.org的解决方案

    为什么有这个? 由于国内网络原因(你懂的),导致 rubygems.org 存放在 Amazon S3 上面的资源文件间歇性连接失败.所以你会与遇到 gem install rack 或 bundle ...

  9. 修改ruby gem源为ruby.taobao.org

    由于网络原因,导致从rubygems.org下载gem文件较慢或者间歇性的连接失败,所以可以修改gem源为ruby.taobao.org.具体可以用 gem install rails -V 来查看执 ...

随机推荐

  1. Java [leetcode 4] Median of Two Sorted Arrays

    问题描述: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of t ...

  2. FFmpeg 维基百科

    FFmpeg是一个自由软件,可以运行音频和视频多种格式的录影.转换.流功能[1],包含了libavcodec ─这是一个用于多个项目中音频和视频的解码器库,以及libavformat——一个音频与视频 ...

  3. liux之我用过的zip解压命令

    用途说明 zip文件是一种常用的压缩文件格式,WinZip.WinRar等压缩软件都支持zip文件格式,就连java的jar包也是zip格式 的,Firefox插件xpi文件也是zip格式的.Linu ...

  4. 【转】Linux时间函数之gettimeofday()函数之使用方法

    原文网址:http://blog.csdn.net/tigerjibo/article/details/7039434 一.gettimeofday()函数的使用方法: 1.简介: 在C语言中可以使用 ...

  5. 无人机DLG生产作业流程

    参考文章 无人机(AVIAN)低空摄影测量作业流程 无人机低空遥感测绘作业流程及主要质量控制点 微型无人机低空摄影测量系 无人机航空摄影测量系统引进与发展 基于复杂地形的无人机航摄系统1∶500 DL ...

  6. (原创)LAMP教程4-用VirtualBox安装64位的centos6.4

    (原创)LAMP教程4-用VirtualBox安装64位的centos6.4 好的,今天就要开始正式的讲一些有营养的东西了,是的,没有错就是讲如何用VirtualBox安装64位的centos6.4 ...

  7. vi--文本编辑常用快捷键之光标移动

    再来一发! 上一篇关于vi/vim的文章中,主要介绍了文本的复制粘贴删除替换等操作,在慢慢的适应vim的过程中,我发现有很多时间实际上是浪费在移动光标上的,特别是行内移动光标.这篇文章就主要是介绍vi ...

  8. Tip提示框另类写法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. [转]Erlang不能错过的盛宴

    Erlang不能错过的盛宴 (快步进入Erlang的世界) 作者:成立涛 (litaocheng@gmail.com) 作为程序员,我们曾经闻听很多“业界动态”,“技术革新”,曾经接触很多“高手箴言” ...

  10. 设置mysql 在mac中的环境变量

    在mac os的用户目录下有一个隐藏文件.bash_profile,编辑它就可以完成环境变量的创建. 比如要将mysql的运行目录加到环境变量中,可以在.bash_profile中新增如下一行: ex ...