views:

132

answers:

2

I keep getting an error when trying to install the geoip_city gem. I've already installed the GeoIP C library to /opt/GeoIP, but the gem doesn't seem to pick it up. I've tried:

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

all of which output this error:

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
A: 

I think you have to pass the ARCHFLAGS parameter to indicate that is going to be built for a 64 bit arquitecture:

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

cantorrodista
Thanks for the reply! My system is only 32 bit though.
tomeara
A: 

cantorrodista was on the right track, though. I had to run the command like this: sudo env ARCHFLAGS="-arch i386" gem install geoip_city -- --with-geoip-dir=/opt/GeoIP

tomeara