bundle geoip-c - 给出错误"你必须安装geoip c库"

时间:2015-11-17 01:59:18

标签: ruby-on-rails ruby geoip

尝试捆绑具有gem geoip-c但获取

的应用
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/durrantm/.rvm/rubies/ruby-2.1.5/bin/ruby -r ./siteconf20151116-4194-j
cyop7.rb extconf.rb
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
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

如何解决这个问题?

我能够brew install geoip,现在brew list geoip显示

/usr/local/Cellar/geoip/1.6.7/bin/geoiplookup
/usr/local/Cellar/geoip/1.6.7/bin/geoiplookup6
/usr/local/Cellar/geoip/1.6.7/include/ (2 files)
/usr/local/Cellar/geoip/1.6.7/lib/libGeoIP.1.dylib
/usr/local/Cellar/geoip/1.6.7/lib/pkgconfig/geoip.pc
/usr/local/Cellar/geoip/1.6.7/lib/ (2 other files)
/usr/local/Cellar/geoip/1.6.7/share/man/ (2 files)
20:59:38 durrantm Michaels-MacBook-Air /Users/durrantm/eq/lynx master

3 个答案:

答案 0 :(得分:10)

要解决此问题,请使用以下命令将以下环境变量设置为geoip lib并包含目录:

env LDFLAGS=`pkg-config geoip --libs-only-L` CFLAGS=`pkg-config geoip --cflags-only-I` gem install geoip-c

答案 1 :(得分:2)

适用于Linux环境

如geoip-c gem自述文件中所述,您需要先安装以下库

  • sudo apt-get install geoip-bin
  • sudo apt-get install geoip-database
  • sudo apt-get install libgeoip-dev

答案 2 :(得分:0)

仅安装libgeoip-dev就足够了