[Mapserver-users] PERL Mapscript under Cygwin
Joe Bussell
joe at otsys.com
Wed Mar 26 14:18:29 PST 2003
Greetings Listers,
Marketing came in the other day insisting on a TrafficDodger that
works complete under Windows. One of the major hurdles for us is our
use of PERL Mapscript for handling dynamic data (routes, incidents &
speeds). One solution was to build Mapscript under Cygwin. I went to
the Wiki, downloaded the latest and greatest, then attempted a build. I
ran into a number of snags which I was able to hack my way around. I
have now produced a useful PERL Mapscript build under Cygwin. Now that
Marketing doesn't care as much any more I thought I would pass on what I
learned before it is meaningless.
The wiki is correct on many points, but there are some gotchas along
the way. First thing, one that seldom is mentioned directly, is that
there is an order to what gets made first. GD needs freetype for one
thing. This is what I did:
1) Build a Cygwin environment with:
build tools (make, cmake, libtool, gcc, flex, bison, ... )
perl
Make sure that you DO NOT have Cygwin's Postgresql installed, this
makes the compile of gdal fail. On multiple machines objdump reported
that pq.dll was an unrecognized format (any ideas on why?)
I didn't bother with the Cygwin native gd or freetype either.
2) Download appropriate sources:
freetype-2.1.3
gd-2.0.11
gdal-1.1.8
proj-4.4.6
mapserver-3.6.5
3) Build freetype.
This is trivial, you will need to run:
./configure
make
make install
4) Build gd
This is trivial, you will need to run:
./configure
make
make install
5) build gdal
This is where things get weird and more work needs to be done. You
will need to run:
./configure
make
make install
edit the installed gdal-config. This is necesary as the install
part of the makefile makes the choice that the library is not shared.
The libraries that gdal-config reports are incorrectly articulated in
the LIBS string. Specifically the '-l' is prepended to all libraries
independent of their shared-ness. If the path ends with a '.a' it
should not be prepended with -l. Additionally, the installer requires
the addition of -l/usr/local/lib/lib which is just clearly wrong. Your
mileage may vary. One build actually went completely correct with no
edit required.
6) Build proj
This is trivial, you will need to run:
./configure
make
make install
7) Build Mapserver
Edit the Makefile.in so the following are correct:
HEADER_INSTALL=/usr/local/include/mapserver-3.6/
LD= g++
then I used
./configure --with-gd --with-proj=/usr/local --with-freetype \
--with-gdal=/usr/local/bin/gdal-config
followed by:
make
make install
8) Now for the PERL Mapscript part. This is also weird and will require
upstream patches to really be correct. To reproduce my hand hack first
you need to run:
perl Makefile.PL
the Makefile you just creaed is not perfect. Edit it such that the
linker is g++ as in step 7.
The link will still fail since gdal was built as a non-shared library.
The linker will need the extra libs to make the dllwrap call work. To
accomplish this I added the back-ticked command
`/usr/local/bin/gdal-config --libs` to the end of the list of LDLOADLIBS.
Why the list isn't properly propagated from LIBS, which is correct in
the Makefile, is unknown to me at this point. It really should be fixed
in MakeMaker.
There is still one extra hook. dllwrap makes use of ld2, which is just
a thin wrapper around perlld in Cygwin. The perlld in /usr/local/bin/
in my Cygwin envoronment tries to use ld as its linker. This fails to
bring in the OGR and GDAL bits. You will need to edit
/usr/local/bin/perlld.exe to have
driver_name = g++;
now you can run
make
make install
You will still have to be sure to fully qualify mapscript objects when
calling 'new' on them. dump.pl in the examples does not do this
correctly (see previous posts).
My hope is that the folks working on gdal can work out the shared
library bits to improve the installed gdal-config. I also would like to
see the Makefiles be built using g++ as the linker when it is available.
I am unsure what my change to perlld will do to other perl builds (ie
CPAN). I have install from CPAN after the change and did not observe
any new problems.
I hope that this is useful to someone as I fear it was an exercise in
futility for me. I am very happy with the uptime of our *nix servers
and am not inclined to push for Windows solutions in the near future.
It could haunt me later however, so I am sending these bits to you folks
hoping for improvements.
Cordially,
Joe Bussell
On Time Systems
www.trafficdodger.com
More information about the MapServer-users
mailing list