Closed whyvez closed 12 years ago
Did you install GDAL first? It looks like it can't find libgdal. This gem is just ruby bindings for GDAL, and not GDAL itself. If you're on a Mac, you install gdal from homebrew:
brew install gdal
To locate GDAL, the gem uses gdal-config
to find the library. So you can test to make sure the library is installed properly from the command line by running which gdal-config
and gdal-config --libs
.
If you're on Linux, you can install it from apt, there's more info in the readme about how to install GDAL.
Yes GDAL is installed. Here are my gdal-config outputs.
gdal-config --version
outputs 1.7.3
gdal-config --libs
outputs -L/usr/lib -lgdal1.7.0
gdal-config --cflags
outputs -I/usr/include/gdal
Hmm, I've only tested this gem with GDAL 1.9.x (Mac and Linux). It seems that older versions installed the libgdal library with a different name (including the version). In either case, I doubt this gem will work with GDAL 1.7.x or 1.8.x because it contains native code that is bound to specific a version of libgdal. There are typically breaking changes in the native API between versions. So even if it could find libgdal1.7.0, the binding would fail to compile/link.
I would recommend (if possible) installing GDAL 1.9 and I bet it will build properly.
OK. Un-installed 1.7 and installed 1.9. Confirmed version was indeed 1.9 using gdal-config. This time installing the gem was successful but it complained when I tried to start my rails server (WEBrick). Here is the error:
/home/yrichard/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require': libgdal.so.1: cannot open shared object file: No such file or directory - /home/yrichard/.rvm/gems/ruby-1.9.3-p194/gems/gdal-0.0.3/lib/gdal-ruby/ogr.so (LoadError)
Getting closer I think!
I'm pretty sure this is an environment related issue because it says it can't find the libgdal.so file. You could try setting LD_LIBRARY_PATH
before running the server so it knows where to find shared libraries. Usually libraries in /usr/lib
and /usr/local/lib
are available, but possibly it's installed somewhere else?
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Note that /usr/local/lib
above should be wherever libgdal
is on your machine.
Here's a related issue that has a more permanent way of adding the path to the environment: http://stackoverflow.com/questions/9104224/geodjango-gdal-library-giving-error
You are my hero! Been on this for 10 hrs straight now and finally working! Still in dev at the moment and hopefully this "gem" will simplify migration over to production. Can't confirm on what actually did it right now but will once I have rolled out production. Many Thanks!!!
I am getting the following error when trying to install the gdal gem: I am using RVM and trying to simply use gdal/ogr in my Rails 3 app.
ERROR: Error installing gdal: ERROR: Failed to build gem native extension.
checking for main() in -lgdal... no * 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=/usr/bin/ruby1.8 --with-gdal-dir --without-gdal-dir --with-gdal-include --without-gdal-include=${gdal-dir}/include --with-gdal-lib --without-gdal-lib=${gdal-dir}/lib --with-gdallib --without-gdallib extconf.rb:9: libgdal not found (RuntimeError)