正在安装 Charlock_Holmes - 无法构建 gem 本机扩展

Installing Charlock_Holmes - Failed to build gem native extension

我对 Ubuntu 和通过终端安装 gem 还很陌生。我在安装 charlock_holmes 时遇到了一些问题。当我尝试安装时,遇到了这个大错误,我无法确定:

ryan@ubuntu:~/Desktop/linguist$ sudo gem install charlock_holmes -v '0.7.3'
Building native extensions.  This could take a while...
ERROR:  Error installing charlock_holmes:
ERROR: Failed to build gem native extension.

    /usr/bin/ruby1.9.1 extconf.rb
checking for main() in -licui18n... yes
checking for main() in -licui18n... yes
checking for unicode/ucnv.h... yes
checking for main() in -lz... yes
checking for main() in -licuuc... yes
checking for main() in -licudata... yes
creating Makefile

make
compiling converter.c
In file included from converter.c:2:0:
common.h:23:14: warning: ‘charlock_new_str’ defined but not used [-Wunused-     function]
static VALUE charlock_new_str(const char *str, size_t len)
          ^
common.h:32:14: warning: ‘charlock_new_str2’ defined but not used [-Wunused-    function]
static VALUE charlock_new_str2(const char *str)
          ^
compiling encoding_detector.c
In file included from encoding_detector.c:2:0:
common.h:14:14: warning: ‘charlock_new_enc_str’ defined but not used [-    Wunused-function]
 static VALUE charlock_new_enc_str(const char *str, size_t len, void     *encoding)
          ^
compiling ext.c
In file included from ext.c:1:0:
common.h:14:14: warning: ‘charlock_new_enc_str’ defined but not used [-    Wunused-function]
 static VALUE charlock_new_enc_str(const char *str, size_t len, void   *encoding)
          ^
common.h:23:14: warning: ‘charlock_new_str’ defined but not used [-Wunused-    function]
 static VALUE charlock_new_str(const char *str, size_t len)
          ^
common.h:32:14: warning: ‘charlock_new_str2’ defined but not used [-Wunused-    function]
static VALUE charlock_new_str2(const char *str)
          ^
compiling transliterator.cpp
make: g++: Command not found
make: *** [transliterator.o] Error 127


Gem files will remain installed in /var/lib/gems/1.9.1/gems/charlock_holmes-    0.7.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/charlock_holmes-0.7.3/ext/charlock_holmes/gem_make.out

我真的不知道下一步该做什么。任何帮助将不胜感激。

从错误日志来看,似乎没有安装g++编译器。请使用此命令安装:

sudo apt-get install g++

然后 运行 这些命令:

sudo apt-get install libicu-dev   
sudo gem install charlock_holmes -v '0.7.3'

注意libicu-dev 是对 charlock_holmes

的机架前依赖

希望这会有所帮助!