安装 geoip_city gem 时出错

Posted

技术标签:

【中文标题】安装 geoip_city gem 时出错【英文标题】:Error installing geoip_city gem 【发布时间】:2010-04-30 23:09:43 【问题描述】:

我在尝试安装 geoip_city gem 时不断收到错误消息。我已经将 GeoIP C 库安装到 /opt/GeoIP,但 gem 似乎没有选择它。我试过了:

sudo gem install geoip_city -- --with-geoip-dir=/opt/GeoIP


sudo gem install geoip_city -- --with-geoip-lib=/opt/GeoIP/lib


sudo gem install geoip_city -- --with-geoip-dir=/opt/GeoIP --with-geoip-lib=/opt/GeoIP/lib

所有这些都输出这个错误:

Building native extensions.  This could take a while...
ERROR:  Error installing geoip_city:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-geoip-lib=/opt/GeoIP/lib
checking for GeoIP_record_by_ipnum() in -lGeoIP... no
you must have geoip c library installed!
*** 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=$opt-dir/include
    --with-opt-lib
    --without-opt-lib=$opt-dir/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    --with-geoip-dir
    --without-geoip-dir
    --with-geoip-include
    --without-geoip-include=$geoip-dir/include
    --with-geoip-lib=$geoip-dir/lib
    --with-GeoIPlib
    --without-GeoIPlib


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/geoip_city-0.2.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/geoip_city-0.2.0/gem_make.out

【问题讨论】:

【参考方案1】:

不过,cantorrodista 是在正确的轨道上。我必须像这样运行命令: sudo env ARCHFLAGS="-arch i386" gem install geoip_city -- --with-geoip-dir=/opt/GeoIP

【讨论】:

【参考方案2】:

我认为您必须传递 ARCHFLAGS 参数以指示将为 64 位架构构建:

sudo env ARCHFLAGS="-arch x86_64" gem install geoip_city -- --with-geoip-dir=/opt/GeoIP

【讨论】:

感谢您的回复!不过我的系统只有 32 位。

以上是关于安装 geoip_city gem 时出错的主要内容,如果未能解决你的问题,请参考以下文章

在 OSX 上安装 rmagick gem 时出错 - 错误:无法构建 gem 原生扩展

尝试使用 mysql2 gem 安装应用程序时出错

在 Windows 8.1 中使用 gem 安装 sass 时出错

通过 Bundler 安装 mysql2 gem 时出错

在 Windows 上安装 json gem 时出错

在 Ubuntu 20.04 上安装 mysql2 gem 版本“0.3.21”时出错