3

我正在尝试在我的 Mac(10.7.5、ruby-1.9.3-p392)上安装 charlock_holmes,但遇到以下错误:

$gem install charlock_holmes -v '0.6.9.4'
Building native extensions.
This could take a while...
ERROR:  Error installing charlock_holmes:
ERROR: Failed to build gem native extension.

/Users/mthompson/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for main() in -licui18n... no
checking for main() in -licui18n... no


***************************************************************************************
*********** icu required (brew install icu4c or apt-get install libicu-dev) ***********
***************************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

我已经通过 macports 安装了 icu,所以我的 icu 目录是/opt/local/lib/icu/opt/local/share/icu. 我尝试使用指定的目录进行安装:

$ gem install charlock_holmes -v '0.6.9.4' -- --with-icu-dir=/opt/local/lib/icu --with-opt-include=/usr/local/include/ --with-opt-lib=/usr/local/lib/

..但我遇到了同样的错误。任何想法都会受到欢迎。

4

3 回答 3

11

我能够使用安装了 macports 的 ICU 版本安装这个 gem,--with-opt-include--with-opt-lib指向/opt.

通过运行成功安装gem:

gem install charlock_holmes -v '0.6.9.4' -- --with-icu-dir=/opt/local/lib/icu --with-opt-include=/opt/local/include/ --with-opt-lib=/opt/local/lib/
于 2013-09-11T20:21:54.017 回答
5

我今天遇到了这个问题。我意识到通过切换到 Homebrew 解决了最初的问题。这对我来说不是一个可接受的解决方案,所以我一直在挖掘。解决方案实际上非常简单。

通过 Macports 安装 icu 后,只需运行以下命令安装 charlock_holmes:

gem install charlock_holmes -- --with-icu-dir=/opt/local

希望这可以帮助遇到此问题并且不愿意放弃 Macports 来解决它的其他人。

于 2014-03-31T23:07:42.743 回答
2

我最终从 MacPorts 切换到 Homebrew 并重新安装了我的 rubies 和软件包。

于 2013-06-18T20:01:41.680 回答