| 1 | = How to Build & Install PerlMapScript = |
| 2 | |
| 3 | Once you compile !MapServer itself and can successfully run './mapserv' and get back: |
| 4 | {{{ |
| 5 | "This script can only be used to decode form results and should be initiated as a CGI process via a httpd server." |
| 6 | }}} |
| 7 | Then |
| 8 | {{{ |
| 9 | cd mapscript/perl |
| 10 | perl Makefile.PL |
| 11 | make |
| 12 | make install |
| 13 | }}} |
| 14 | == Changing the Perl Module Name == |
| 15 | |
| 16 | The default module name is "mapscript". However, you may want to use something version specific, especially if you have multiple versions installed. To do this: |
| 17 | |
| 18 | 1) edit mapscript.i and change the line "%module mapscript" to "%module yourname" |
| 19 | 2) remove mapscript.pm if it's present. SWIG will create yourname.pm and the presence of mapscript.pm will confuse the intall. |
| 20 | 3) re-SWIG it (install SWIG and the type swig -shadow -perl5 mapscript.i) |
| 21 | 4) edit Makefile.PL and change the line "'NAME' => 'mapscript'," to "'NAME' => 'yourname'," |
| 22 | 5) build as normal |
| 23 | |
| 24 | You should now be able to do "use yourname" in your perl scripts. |
| 25 | |
| 26 | == What to Check When Encountering Build Issues == |
| 27 | {{{ |
| 28 | /sbin/ldconfig -v |
| 29 | }}} |
| 30 | will give information concerning the shared libraries present |
| 31 | on your system. |
| 32 | {{{ |
| 33 | ldd mapserv |
| 34 | }}} |
| 35 | Look for the path that is listed. |
| 36 | Then make sure this path is part of your runtime library path, |
| 37 | for this you have two options, assuming you're running Linux: |
| 38 | |
| 39 | 1- add the path to /etc/ld.so.conf and run 'ldconfig' as root |
| 40 | |
| 41 | or |
| 42 | |
| 43 | 2- Use SetEnv LD_LIBRARY_PATH to specify this path in your |
| 44 | apache httpd.conf |
| 45 | {{{ |
| 46 | echo $LD_LIBRARY_PATH |
| 47 | }}} |
| 48 | Will give information on the library path traversed when |
| 49 | linking. |
| 50 | {{{ |
| 51 | locate <library_name_ie._gd.h> |
| 52 | }}} |
| 53 | Will give location(s) of the specified filename. |
| 54 | |
| 55 | Does the above information show a mixture of include files (different revisions of the same library). |
| 56 | |
| 57 | If when running ./mapserv you receive the error message: |
| 58 | {{{ |
| 59 | mapserv:error while loading libraries:libproj.so.0 cannot open shared object file : No such file or directory. |
| 60 | }}} |
| 61 | Run '/sbin/ldconfig -v | grep libproj'. |
| 62 | |
| 63 | Which should return something similar to "libproj.so.0" |
| 64 | If not try reinstalling proj.4 |
| 65 | |
| 66 | If when running ./mapserv you recieve the error message: |
| 67 | {{{ |
| 68 | error while loading shared libraries :/usr/libwwwappp.so.0 undefined symbol: HTZlib_inflate |
| 69 | }}} |
| 70 | Check /usr/lib and /usr/local/lib for a copy of w3c-libwww. |
| 71 | If both have a copy then remove the copy in /usr/lib. |
| 72 | The cleanest way to remove, is to 'rpm -q -a | grep w3c-libwww' & do 'rpm -e w3c-libwww-<version_number>'. |
| 73 | |
| 74 | If when compiling you get an error: |
| 75 | {{{ |
| 76 | mapscript_wrap.c: In function `SWIG_GetPtr?': |
| 77 | mapscript_wrap.c:292: `sv_undef' undeclared (first use in this function) |
| 78 | }}} |
| 79 | (followed by many more errors) |
| 80 | |
| 81 | Find the DEFINE line in Makefile and add -DPERL_POLLUTE at the end. |
| 82 | |
| 83 | == Instead of compiling == |
| 84 | (or at least as a starting point) install ftp://ftp.intevation.de/freegis/gnu-linux-i586/updates . |
| 85 | |
| 86 | == To Compile w/ Perl 5.8 == |
| 87 | |
| 88 | (submitted by Joe Bussell) |
| 89 | you must make a hand hack to the generated SWIG code in mapscript_wrap.c |
| 90 | Specifically, the macro XS(boot_mapscript) must be declared if the PERL object is not declared. |
| 91 | In my world line 431 which reads SWIGEXPORT(void) boot_mapscript(CV* cv); should be replaced with XS(boot_mapscript); |
| 92 | |
| 93 | == 3.6.4 Compiles but Does NOT Run == |
| 94 | Bails with Can't load '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris-64int/auto/mapscript/mapscript.so' ... |
| 95 | |
| 96 | (submitted by unknown user) |
| 97 | Apparently, the flag "-lgd" isn't being placed in ../../perlvars and this is causing the problem. A rather simple, though barbaric, solution is to add this line: |
| 98 | {{{ |
| 99 | $libs .= " -lgd"; |
| 100 | }}} |
| 101 | right before this in Makefile.PL: |
| 102 | {{{ |
| 103 | print $inc."\n"; |
| 104 | print $libs."\n"; |
| 105 | }}} |
| 106 | == Building Private MapScript (Shared ISP Machine) == |
| 107 | |
| 108 | When you are installing a private version of mapscript, there is a perl Makefile bug (at least on perl 5.6.1 and maybe later versions) that must be manually fixed to avoid conflict with installed version of libraries on the machine (in /usr/lib or /usr/local/lib) |
| 109 | |
| 110 | In the the mapserver/mapscript/perl directory, |
| 111 | {{{ |
| 112 | perl Makefile.PL PREFIX=/usr/home/myhomedir LIB=/usr/home/myhomedir/usr/local/lib |
| 113 | }}} |
| 114 | * note: the PREFIX and LIB are needed to create your private version |
| 115 | |
| 116 | and where /usr/home/myhomedir is my homedir and my privatedir are is built in /usr/home/myhomedir/usr/local |
| 117 | |
| 118 | perl MakeMaker? will create a canned Makefile template... and if you inspect the file, you will see: |
| 119 | {{{ |
| 120 | LDDLFLAGS = -shared -L/usr/local/lib |
| 121 | LDFLAGS = -Wl,-E -L/usr/local/lib |
| 122 | }}} |
| 123 | and when change to: |
| 124 | {{{ |
| 125 | LDDLFLAGS = -shared -L/usr/home/myhomedir/usr/local/lib |
| 126 | LDFLAGS = -Wl,-E -L/usr/home/myhomedir/usr/local/lib |
| 127 | }}} |
| 128 | and then |
| 129 | {{{ |
| 130 | make make install |
| 131 | }}} |
| 132 | Mapscript *should* find your private copy of libgd (and other packages) and link to them. I learn this lesson the hard way, and I thought I'd better stick it in the wiki. |
| 133 | |
| 134 | Private Perl Module Usage: When you try to "use mapserver;" in perl, you will have to add a "use lib ..." preceding that line. |
| 135 | {{{ |
| 136 | use lib("/usr/home/myhomedir/lib/site_perl"); |
| 137 | use mapscript; |
| 138 | }}} |
| 139 | -mapsurfer 06/04/2003 |
| 140 | |
| 141 | == Ways to Change the Perl @INC Path == |
| 142 | |
| 143 | As usual there are many ways to do it. You need to alter the default @INC array. You can use on first line of your script: |
| 144 | |
| 145 | 1. !/usr/bin/perl -I/installs # puts /installs at front of @INC. |
| 146 | |
| 147 | or: push @INC, '/installs'; # puts it at the end of @INC. |
| 148 | |
| 149 | or: use lib '/installs/'; # not sure where this puts it. |
| 150 | |
| 151 | But the order is important, if the two modules have identical names. |
| 152 | |
| 153 | You might also try: require '/installs/gd-2.0.15'; |
| 154 | |
| 155 | Of course, to get mapserver to use the new GD you'll need to recompile it. |
| 156 | |
| 157 | Eric |