[GRASS-dev] Re: winGRASS

Paul Kelly paul-grass at stjohnspoint.co.uk
Tue Dec 12 15:58:26 EST 2006


Hello Moritz
I've got a bit further with documenting what I was doing. See attached for 
some of my notes. Mostly on compiling the accompanying libraries GRASS 
absolutely needs:
XDR
Zlib
libpng
PROJ.4
GDAL

I put these into a gzipped tar file in case anybody would like to get 
started quickly - in this case you would just need Msys,Mingw with bison 
and flex. Everything else included in here:
http://www.stjohnspoint.co.uk/grass/wingrass-extralibs.tar.gz
and then the prefix where you untar that file you will need to supply to 
the GRASS configure as:
--with-includes=prefix --with-libs=prefix
FWIW my configure line was:
./configure --prefix=c:/grass --bindir=c:/grass/bin \
--with-includes=/c/grass/forgrass/include \
--with-libs=/c/grass/forgrass/lib --with-cxx --without-jpeg --without-tiff \
--without-postgres --with-opengl=windows --without-fftw --without-x \
--enable-x11=no --enable-shared=yes --with-tcltk-includes=/c/tcl/include \
--with-tcltk-libs=/c/tcl/bin

After compiling you should copy libxdr.dll, libproj.dll, libpng.dll, 
libgdal-1.dll and libz.dll.1.2.3 into the GRASS lib directory and all the 
GDAL and PROJ .exe files in the bin directory into the GRASS bin 
directory, and then you have a more or less self-contained GRASS 
distribution.

I also installed Activestate Tcl/Tk 8.4.13 (in c:\tcl).

I could make a binary distribution that sort of works OK to a certain 
extent without having Msys/Mingw installed, only thing is I want to wait 
until Nviz is working again on Windows as it was up to yesterday. The 
problem is starting it from a script. Scripts are very problematic (and of 
course only possible at all if you have Msys installed) because of the way 
Msys handles Windows paths.

If you have Msys and Mingw installed, putting their bin directories in the 
PATH makes things in general run more smoothly, but of course that's 
cheating!

Paul
-------------- next part --------------
Download and run the MinGW installer. Let it download and install what it needs.

Also install:
flex from gnuwin32.sourceforge.net and put flex.exe in Mingw bin directory
Use bison from Mingw as Gnuwin32 bison looks for libintl3.dll

Download pdcurses from Mingw download page.
Install in directory prefix where libraries needed for GRASS are going.
Rename libpdcurses.a to libcurses.a (only need this and curses.h)
TODO: compile this from scratch and make it a shared DLL to save disk space.

Run Msys installer and let it install default stuff.

XDR: download from Glynn's link.
need to copy in config.guess from GRASS.
Also a patch:
diff -ur xdr-orig/Makefile.in xdr-pk/Makefile.in
--- xdr-orig/Makefile.in	Fri Nov 18 16:13:16 2005
+++ xdr-pk/Makefile.in	Mon Dec 11 22:18:34 2006
@@ -19,24 +19,27 @@
 
 HDRS = rpc/types.h rpc/xdr.h
 
-all xdrlib: libxdr.a
+all xdrlib: libxdr.dll
 
 libxdr.a: ${OBJS}
 	@echo "building libxdr.a"
 	${AR} cru libxdr.a ${OBJS}
 
-install: $(HDRS) libxdr.a
+libxdr.dll: ${OBJS}
+	@echo "building libxdr.dll"
+	${CC} -shared -o libxdr.dll ${OBJS} -lwsock32
+
+install: $(HDRS) libxdr.dll
 	@echo "Creating RPC header directory"
-	-mkdir -p ${prefix}/include/rpc && \
-		chmod 755 ${prefix}/include/rpc
+	-mkdir -p -m 755 ${prefix}/include/rpc
 	@echo "Installing XDR header files"
 	-set -x;for i in $(HDRS) ; do \
 		(install -c -m 644 $$i ${prefix}/include/rpc) done
 	@echo "Installing XDR library"
-	install -c -m 644 libxdr.a ${prefix}/lib
-	${RANLIB} ${prefix}/lib/libxdr.a
+	-mkdir -p -m 755 ${prefix}/lib
+	install -c -m 644 libxdr.dll ${prefix}/lib
 
 
 clean:
-	rm -f *.o libxdr.a
+	rm -f *.o libxdr.dll
 
diff -ur xdr-orig/xdr_array.c xdr-pk/xdr_array.c
--- xdr-orig/xdr_array.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_array.c	Mon Dec 11 22:06:28 2006
@@ -41,6 +41,8 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include <rpc/types.h>
 #include <rpc/xdr.h>
@@ -95,7 +97,7 @@
 					"xdr_array: out of memory\n");
 				return (FALSE);
 			}
-			bzero(target, nodesize);
+			memset(target, 0, (size_t)nodesize);
 			break;
 
 		case XDR_FREE:
diff -ur xdr-orig/xdr_mem.c xdr-pk/xdr_mem.c
--- xdr-orig/xdr_mem.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_mem.c	Mon Dec 11 22:09:45 2006
@@ -42,6 +42,7 @@
  *
  */
 
+#include <string.h>
 
 #include <rpc/types.h>
 #include <rpc/xdr.h>
@@ -126,7 +127,7 @@
 
 	if ((xdrs->x_handy -= len) < 0)
 		return (FALSE);
-	bcopy(xdrs->x_private, addr, len);
+	memmove(addr, xdrs->x_private, (size_t)len);
 	xdrs->x_private += len;
 	return (TRUE);
 }
@@ -140,7 +141,7 @@
 
 	if ((xdrs->x_handy -= len) < 0)
 		return (FALSE);
-	bcopy(addr, xdrs->x_private, len);
+	memmove(xdrs->x_private, addr, (size_t)len);
 	xdrs->x_private += len;
 	return (TRUE);
 }
diff -ur xdr-orig/xdr_rec.c xdr-pk/xdr_rec.c
--- xdr-orig/xdr_rec.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_rec.c	Mon Dec 11 22:10:58 2006
@@ -49,6 +49,9 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 //#include <netinet/in.h>
@@ -279,7 +282,7 @@
 	while (len > 0) {
 		current = (u_int)rstrm->out_boundry - (u_int)rstrm->out_finger;
 		current = (len < current) ? len : current;
-		bcopy(addr, rstrm->out_finger, current);
+		memmove(rstrm->out_finger, addr, (size_t)current);
 		rstrm->out_finger += current;
 		addr += current;
 		len -= current;
@@ -530,7 +533,7 @@
 			continue;
 		}
 		current = (len < current) ? len : current;
-		bcopy(rstrm->in_finger, addr, current);
+		memmove(addr, rstrm->in_finger, (size_t)current);
 		rstrm->in_finger += current;
 		addr += current;
 		len -= current;
diff -ur xdr-orig/xdr_reference.c xdr-pk/xdr_reference.c
--- xdr-orig/xdr_reference.c	Fri Nov 18 16:13:16 2005
+++ xdr-pk/xdr_reference.c	Mon Dec 11 22:05:35 2006
@@ -41,6 +41,8 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 
@@ -77,7 +79,7 @@
 				    "xdr_reference: out of memory\n");
 				return (FALSE);
 			}
-			bzero(loc, (int)size);
+			memset(loc, 0, (size_t)size);
 			break;
 	}
 

./configure --prefix=/c/grass/forgrass
make
make install


zlib-1.2.3
A patch:
--- orig/zlib-1.2.3/configure	Mon Jul 11 22:11:57 2005
+++ pk/zlib-1.2.3/configure	Mon Dec 11 22:57:11 2006
@@ -79,6 +79,11 @@
   Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
   CYGWIN* | Cygwin* | cygwin* | OS/2* )
              EXE='.exe';;
+  MINGW32* )
+             shared_ext='.dll'
+             SFLAGS=${CFLAGS}
+             LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.dll.1"}
+             EXE='.exe';;
   QNX*)  # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
          # (alain.bonnefoy at icbt.com)
                  LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;

./configure --shared --prefix=/c/grass/forgrass
make
make install

libpng 1.2.12-noconfig

cp scripts/makefile.mingw ./Makefile

Make it.
Then I added a bit to the Makefile to create a shared library:
libpng.dll: $(OBJS)
        gcc -shared -o $@ $(OBJS) -L$(ZLIBLIB) -lz

make libpng.dll
install to lib directory manually and same for png.h and pngconf.h into include.

PROJ 4.5.0
./configure --enable-shared --disable-static --prefix=/c/grass/forgrass

make but then delete libraries and executables created and do this
cd src/.libs
gcc -shared -o libproj.dll -lm PJ_aeqd.o PJ_gnom.o PJ_laea.o PJ_mod_ster.o PJ_nsper.o PJ_nzmg.o PJ_ortho.o PJ_stere.o PJ_sterea.o PJ_aea.o PJ_bipc.o PJ_bonne.o PJ_eqdc.o PJ_imw_p.o PJ_krovak.o PJ_lcc.o PJ_mpoly.o PJ_poly.o PJ_rpoly.o PJ_sconics.o proj_rouss.o PJ_cass.o PJ_cc.o PJ_cea.o PJ_eqc.o PJ_gall.o PJ_labrd.o PJ_lsat.o PJ_merc.o PJ_mill.o PJ_ocea.o PJ_omerc.o PJ_somerc.o PJ_tcc.o PJ_tcea.o PJ_tmerc.o PJ_airy.o PJ_aitoff.o PJ_august.o PJ_bacon.o PJ_chamb.o PJ_hammer.o PJ_lagrng.o PJ_larr.o PJ_lask.o PJ_nocol.o PJ_ob_tran.o PJ_oea.o PJ_tpeqd.o PJ_vandg.o PJ_vandg2.o PJ_vandg4.o PJ_wag7.o PJ_lcca.o PJ_geos.o PJ_boggs.o PJ_collg.o PJ_crast.o PJ_denoy.o PJ_eck1.o PJ_eck2.o PJ_eck3.o PJ_eck4.o PJ_eck5.o PJ_fahey.o PJ_fouc_s.o PJ_gins8.o PJ_gn_sinu.o PJ_goode.o PJ_hatano.o PJ_loxim.o PJ_mbt_fps.o PJ_mbtfpp.o PJ_mbtfpq.o PJ_moll.o PJ_nell.o PJ_nell_h.o PJ_putp2.o PJ_putp3.o PJ_putp4p.o PJ_putp5.o PJ_putp6.o PJ_robin.o PJ_sts.o PJ_urm5.o PJ_urmfps.o PJ_wag2.o PJ_wag3.o PJ_wink1.o PJ_wink2.o pj_latlong.o pj_geocent.o aasincos.o adjlon.o bch2bps.o bchgen.o biveval.o dmstor.o mk_cheby.o pj_auth.o pj_deriv.o pj_ell_set.o pj_ellps.o pj_errno.o pj_factors.o pj_fwd.o pj_init.o pj_inv.o pj_list.o pj_malloc.o pj_mlfn.o pj_msfn.o proj_mdist.o pj_open_lib.o pj_param.o pj_phi2.o pj_pr_list.o pj_qsfn.o pj_strerrno.o pj_tsfn.o pj_units.o pj_zpoly1.o rtodms.o vector1.o pj_release.o pj_gauss.o nad_cvt.o nad_init.o nad_intr.o emess.o pj_apply_gridshift.o pj_datums.o pj_datum_set.o pj_transform.o geocent.o pj_utils.o pj_gridinfo.o pj_gridlist.o jniproj.o

install libproj.dll /c/grass/forgrass/lib

cd ..
sh-2.04$ ls -l *exe
-rwxr-xr-x    1 Paul     Administ   621579 Dec 11 23:35 cs2cs.exe
-rwxr-xr-x    1 Paul     Administ    77539 Dec 11 23:35 geod.exe
-rwxr-xr-x    1 Paul     Administ    26045 Dec 11 23:35 nad2bin.exe
-rwxr-xr-x    1 Paul     Administ   143429 Dec 11 23:35 nad2nad.exe
-rwxr-xr-x    1 Paul     Administ   592770 Dec 11 23:35 proj.exe

gcc -g -O2 -o cs2cs.exe cs2cs.o gen_cheb.o p_series.o emess.o -L/c/grass/forgrass/lib -lproj
gcc -g -O2 -o geod.exe geod.o geod_set.o geod_for.o geod_inv.o emess.o -L/c/grass/forgrass/lib -lproj
gcc -g -O2 -o nad2bin.exe nad2bin.o
gcc -g -O2 -o nad2nad.exe nad2nad.o emess.o -L/c/grass/forgrass/lib -lproj
gcc -g -O2 -o proj.exe proj.o gen_cheb.o p_series.o emess.o -L/c/grass/forgrass/lib -lproj

sh-2.04$ ls -l *exe
-rwxr-xr-x    1 Paul     Administ    55485 Dec 12 09:43 cs2cs.exe
-rwxr-xr-x    1 Paul     Administ    55002 Dec 12 09:48 geod.exe
-rwxr-xr-x    1 Paul     Administ    26045 Dec 12 09:47 nad2bin.exe
-rwxr-xr-x    1 Paul     Administ    44650 Dec 12 09:49 nad2nad.exe
-rwxr-xr-x    1 Paul     Administ    64185 Dec 12 09:49 proj.exe


mkdir -p /c/grass/forgrass/bin
for i in *exe ; do install $i /c/grass/forgrass/bin ; done

for i in projects.h nad_list.h proj_api.h org_proj4_Projections.h ; do install -m 644 $i /c/grass/forgrass/include ; done

GDAL 1.4.0 beta1

./configure --prefix=/c/grass/forgrass --enable-shared --with-libz=/c/grass/forgrass --with-png=/c/grass/forgrass 

make
make install
If you want you could move libgdal-1.dll from bin/ to lib/ and edit libgdal.la to reflect this.
Rename ogr* to ogr*exe


More information about the grass-dev mailing list