[geos-devel] Perl bindings via SWIG
Ari Jolma
ari.jolma at tkk.fi
Sun Jul 30 15:55:19 EDT 2006
Hello,
Here's a report on building Perl bindings for GEOS on MinGW using the 2.2.3
release.
Configuration, compilation and installation of GEOS went without problems. Then
I created perl subdir under swig and tried building the bindings. After the
effort a simple test script runs ok. Here's what I did:
1. added
#ifdef SWIGPERL
%include ../perl/perl.i
#endif
to geos.i
2. created perl.i with just one line (taken from ruby.i):
%rename(next_) geos::GeometryCollectionIterator::next();
3. ran swig (in msys) with arguments: -c++ -perl5 -o geos_wrap.cxx ../geos.i
The resulting geos_wrap.cxx had to be fixed by adding
#ifdef select
#undef select
#endif
Around "Workaround perl5 global namespace..."
4. created the test script test.pl (this is one of the python tests):
use Test::More qw(no_plan);
BEGIN{ use_ok( 'geos' ); }
$gf = geos::GeometryFactory->new();
$x = 492187.0;
$y = 4493034.0;
$z = 1500.0;
$c = geos::Coordinate->new($x, $y, $z);
$p = $gf->createPoint($c);
ok($p->{x} == $x);
ok($p->{y} == $y);
5. created very standard Makefile.PL:
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'geos',
LD => "g++",
LIBS => "-lgeos.dll",
INC => '-I../../source/headers',
OBJECT => 'geos_wrap.o'
);
and ran "perl Makefile.PL", which produces the Makefile. That I had to fix with
-Wl,--enable-runtime-pseudo-reloc in the dynamic_lib section in the $(LD)
commands (this could perhaps be fixed already in the Makefile.PL)
Then I just ran "dmake test", which builds the Perl module and runs the test script.
I'll probably do more tests with the module later, but this looks promising --
and the annoying things that I had to fix are assumably non-problems under
Linux. Thanks for Sean and Charlie for setting up the environment.
Regards,
Ari
--
Prof. Ari Jolma
Kartografia ja Geoinformatiikka / Cartography and Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma
More information about the geos-devel
mailing list