mapnik / Ruby-Mapnik

Ruby Bindings for Mapnik
MIT License
66 stars 13 forks source link

Compile error for ubuntu 12.04: boost/make_shared.hpp missing #39

Closed wstrinz closed 11 years ago

wstrinz commented 11 years ago

I've been trying to install the gem on ubuntu 12.04.

The best luck I've had so far is using the ppas on https://github.com/mapnik/mapnik/wiki/UbuntuInstallation, but the gem's failing to compile now.

I've tried with gem install ruby_mapnik, and cloning the repo and running rake. Both give me

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

/home/wstrinz/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
extconf.rb:38:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:38:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:39:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
creating Makefile

make
compiling _mapnik_feature.rb.cpp
cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for     C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid for     C/ObjC but not for C++ [enabled by default]
_mapnik_feature.rb.cpp:24:33: fatal error: boost/make_shared.hpp: No such file or     directory
compilation terminated.
make: *** [_mapnik_feature.rb.o] Error 1

I'm guessing based on the fatal error: boost/make_shared.hpp: No such file or directory line that there may be a problem with my libboost installation, but I'm not sure how to go about attacking it.

Using ruby-2.0.0-p247 by the way.

Thanks!

springmeyer commented 11 years ago

It looks like you don't have the boost development headers installed. Try sudo apt-get install libboost-dev

wstrinz commented 11 years ago

Thanks for the quick reply :)

I've installed libboost-dev as part of the instructions on the ubuntu installation page already, but since I tried a couple of different ways of getting it to that point I may have screwed something up along the way. I purged everything and built mapnik from the v2.1 source, and now I'm getting a different error (installing from the git repo) complaining that agg_trans_affine.h is missing:

rake
cd tmp/x86_64-linux/ruby_mapnik/2.0.0
make
compiling ../../../../ext/ruby_mapnik/_mapnik_map.rb.cpp
cc1plus: warning: command line option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from /usr/local/include/mapnik/cairo_context.hpp:35:0,
             from /usr/local/include/mapnik/graphics.hpp:40,
             from ../../../../ext/ruby_mapnik/_mapnik_map.rb.cpp:36:
/usr/local/include/mapnik/gradient.hpp:27:30: fatal error: agg_trans_affine.h: No such file or directory
compilation terminated.
make: *** [_mapnik_map.rb.o] Error 1
rake aborted!
Command failed with status (2): [make...]
/home/wstrinz/.rvm/gems/ruby-2.0.0-p247/gems/rake-compiler-0.9.1/lib/rake/extensiontask.rb:152:in `block (2 levels) in define_compile_tasks'
/home/wstrinz/.rvm/gems/ruby-2.0.0-p247/gems/rake-compiler-0.9.1/lib/rake/extensiontask.rb:151:in `block in define_compile_tasks'
/home/wstrinz/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/home/wstrinz/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => default => test => compile => compile:x86_64-linux => compile:ruby_mapnik:x86_64-linux => copy:ruby_mapnik:x86_64-linux:2.0.0 => tmp/x86_64-linux/ruby_mapnik/2.0.0/ruby_mapnik.so
(See full trace by running task with --trace)

Looks like its from libcairo, so i tried apt-get install libcairo2 libcairo2-dev python-cairo python-cairo-dev libcairomm-1.0-1 libcairomm-1.0-dev, but no luck.

Progress!

springmeyer commented 11 years ago

Sorry about the trouble. I would recommend you use mapnik v2.2.0 from PPA (which will bring in boost 1.49) + ruby-mapnik from master here. If you hit any problems with that combination then it should be easy for me to fix on the spot.

wstrinz commented 11 years ago

Not at all, thanks for helping. I've reinstalled from the PPA, and I'm able to install the gem, but when I run the demo script, it seems to fail because it can't load proj4

ruby demo/rundemo.rb 
/home/wstrinz/Documents/mapnik/git/Ruby-Mapnik/lib/ruby_mapnik/mapnik/map.rb:159:in `__render_to_file__': Cannot initialize proj_transform for given projections without proj4 support (-DMAPNIK_USE_PROJ4): '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs'->'+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs' (RuntimeError)

I tried installing libproj-dev, libproj0, proj-bin, and proj.

wstrinz commented 11 years ago

It is working fine with most other mapnik functions though, so feel free to close this issue.

Thanks for all your help!

springmeyer commented 11 years ago

Lacking proj4 support -DMAPNIK_USE_PROJ4 is a compile time option in Mapnik. This should be enabled in the v2.2.0 Mapnik PPA. So perhaps you ended up installing Mapnik from source? If so, then you need to recompile mapnik after installing libproj-dev. But yeah, it is an optional feature, so not totally necessary.

wstrinz commented 11 years ago

Tried again on a clean ubuntu installation, everything went fine. My advice to anyone coming across this: don't try to install mapnik from the source.