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

Kan*_*ery 0 ruby ubuntu rubygems

我对 Ubuntu 很陌生,并且通过终端安装 gems。我在安装 charlock_holmes 时遇到了一些问题。当我尝试安装时,遇到了这个大错误,我无法弄清楚:

\n\n
ryan@ubuntu:~/Desktop/linguist$ sudo gem install charlock_holmes -v '0.7.3'\nBuilding native extensions.  This could take a while...\nERROR:  Error installing charlock_holmes:\nERROR: Failed to build gem native extension.\n\n    /usr/bin/ruby1.9.1 extconf.rb\nchecking for main() in -licui18n... yes\nchecking for main() in -licui18n... yes\nchecking for unicode/ucnv.h... yes\nchecking for main() in -lz... yes\nchecking for main() in -licuuc... yes\nchecking for main() in -licudata... yes\ncreating Makefile\n\nmake\ncompiling converter.c\nIn file included from converter.c:2:0:\ncommon.h:23:14: warning: \xe2\x80\x98charlock_new_str\xe2\x80\x99 defined but not used [-Wunused-     function]\nstatic VALUE charlock_new_str(const char *str, size_t len)\n          ^\ncommon.h:32:14: warning: \xe2\x80\x98charlock_new_str2\xe2\x80\x99 defined but not used [-Wunused-    function]\nstatic VALUE charlock_new_str2(const char *str)\n          ^\ncompiling encoding_detector.c\nIn file included from encoding_detector.c:2:0:\ncommon.h:14:14: warning: \xe2\x80\x98charlock_new_enc_str\xe2\x80\x99 defined but not used [-    Wunused-function]\n static VALUE charlock_new_enc_str(const char *str, size_t len, void     *encoding)\n          ^\ncompiling ext.c\nIn file included from ext.c:1:0:\ncommon.h:14:14: warning: \xe2\x80\x98charlock_new_enc_str\xe2\x80\x99 defined but not used [-    Wunused-function]\n static VALUE charlock_new_enc_str(const char *str, size_t len, void   *encoding)\n          ^\ncommon.h:23:14: warning: \xe2\x80\x98charlock_new_str\xe2\x80\x99 defined but not used [-Wunused-    function]\n static VALUE charlock_new_str(const char *str, size_t len)\n          ^\ncommon.h:32:14: warning: \xe2\x80\x98charlock_new_str2\xe2\x80\x99 defined but not used [-Wunused-    function]\nstatic VALUE charlock_new_str2(const char *str)\n          ^\ncompiling transliterator.cpp\nmake: g++: Command not found\nmake: *** [transliterator.o] Error 127\n\n\nGem files will remain installed in /var/lib/gems/1.9.1/gems/charlock_holmes-    0.7.3 for inspection.\nResults logged to /var/lib/gems/1.9.1/gems/charlock_holmes-0.7.3/ext/charlock_holmes/gem_make.out\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n

Kh *_*mad 5

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

sudo apt-get install g++
Run Code Online (Sandbox Code Playgroud)

然后运行这些命令:

sudo apt-get install libicu-dev   
sudo gem install charlock_holmes -v '0.7.3'
Run Code Online (Sandbox Code Playgroud)

注意libicu-dev是预机架依赖性charlock_holmes

希望这会有所帮助!