Changes between Version 11 and Version 12 of CompileOnWindows


Ignore:
Timestamp:
Mar 17, 2009, 6:58:18 AM (15 years ago)
Author:
cnielsen
Comment:

Re-written from Marco Pasetti's site but changed to be within osgeo4w directory structure

Legend:

Unmodified
Added
Removed
Modified
  • CompileOnWindows

    v11 v12  
    33== An overview of the dependencies required for building with MingW ==
    44
    5 We use a simplified approach with pre-built libraries for all the GRASS dependencies.
     5We would like use a simplified approach with pre-built libraries for all the GRASS dependencies but for the moment compiling many of the dependencies is required in order to have the proper files for grass. Still, a few steps are eliminated if compilation is done within the '''OSGeo4W''' directory structure.
     6
     7=== Install the OSGeo4W directory structure ===
     8
     9OSGeo4W has several of the required dependencies for compiling GRASS:
     10
     111. Download the '''OSGeo4W installer''' from [http://download.osgeo.org/osgeo4w/osgeo4w-setup.exe here].
     122. Run the installer.
     133. Select Advanced Install, and Next.
     144. Set the install directory to c:\OSGeo4W (other directories or fine if there are no spaces in the path but make sure to adjust the instructions below (?))
     155. Select '''grass''' from the desktop section (this is a binary but we'll compile from source later).
     166. Also select '''msys''' from the command line section and '''libxdr''' from libs
     177. Click next, the selected packages and their required subpackages will be downloaded and installed automatically.
    618
    719=== Install the environment for compilation (MingW) ===
    820
    9 MSYS supplies many utilities from UNIX world in Windows:
    10 
    11 1. Download the '''MSYS installer''' from [http://prdownloads.sourceforge.net/mingw/MSYS-1.0.11-2004.04.30-1.exe here].
    12 
    13     Install to c:\msys
    14     At the command prompt question for post install, type n and then enter.
    15 
    16 2. Download the '''MSYS coreutils package''' from [http://downloads.sourceforge.net/mingw/coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2 here]: -> MSYS Base System (currently MSYS-1.0.11)
    17 
    18     Unpack it to a temporary folder, then copy all the content of the coreutils-5.97 folder to c:\msys (overwrite the existing files when asked)
    19 
    20 3. Download the '''MinGW installer''' from [http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe here]
    21 
    22     - Run and select "Download and Install,  "Current Version";
    23     - Install only "g++ compiler" and "MinGW Make";
    24     - Install to c:\msys\mingw (so, into a new folder) - this will download various tools and install them
    25 
    26 4. Download and install Python 2.x from [http://www.python.org/download/ here]: use their Windows installer to install it on your system (doesn't matter where).
    27 
    28 5. Download and install wxPython from [http://www.wxpython.org/download.php#binaries here] (select version according to Python version taken above)
    29 
    30 6. more?
    31 
    32 === Installing PROJ4 library ===
    33 
    34 ''(untested)''
    35 
    36  * Binaries: http://download.osgeo.org/osgeo4w/release/proj/proj-4.6.1-1.tar.bz2
    37 
    38     Unpack it to c:\msys\. This will "insert" the files into the right directories.
    39 
    40 Question: How to use instead OSGeo4W-Proj4 binaries via installer?
    41 
    42 
    43 === Installing GDAL library ===
    44 
    45 ''(untested)''
    46 
    47  *  Binaries: http://download.osgeo.org/osgeo4w/release/gdal/gdal16/gdal16-1.6.0-8.tar.bz2
    48 
    49     Unpack it to c:\msys\. This will "insert" the files into the right directories.
    50 
    51 Question: How to use instead OSGeo4W-GDAL via installer?
    52 
     211. Run msys (there should be an icon on the desktop)
     222. type:
     23{{{
     24 mkdir /c/osgeo4w/apps/msys/osgeo4w
     25}}}
     263. Open c:\osgeo4w\apps\msys\etc\fstab.sample
     274. Add the line below and save as fstab
     28{{{
     29c:\osgeo4w\     /osgeo4w
     30}}}
     315. Download the MinGW packages:
     32'''mingw32-make''' from [http://downloads.sourceforge.net/mingw/mingw32-make-3.81-20080326-3.tar.gz here]
     33'''gcc-core''' from [http://downloads.sourceforge.net/mingw/gcc-core-3.4.5-20060117-3.tar.gz here]
     34'''gcc-g++''' from [http://downloads.sourceforge.net/mingw/gcc-g++-3.4.5-20060117-3.tar.gz here]
     35'''w32api''' from [http://downloads.sourceforge.net/mingw/w32api-3.13-mingw32-dev.tar.gz here]
     36'''mingw-utils''' from [http://downloads.sourceforge.net/mingw/mingw-utils-0.3.tar.gz here]
     37
     38    Unpack to c:\osgeo4w
     39
     40=== Flex & Bison ===
     41
     42Download:
     43'''flex''' from [http://downloads.sourceforge.net/gnuwin32/flex-2.5.4a-1-bin.zip here]
     44'''bison''' from [http://downloads.sourceforge.net/gnuwin32/bison-2.1-bin.zip here]
     45'''bison-deps''' from [http://downloads.sourceforge.net/gnuwin32/bison-2.1-dep.zip here]
     46
     47    Unpack all to c:\osgeo4w
     48
     49=== PDCurses ===
     50
     51Download PDCurses from [http://downloads.sourceforge.net/pdcurses/PDCurses-3.3.tar.gz here]
     52
     53    Unpack to c:\osgeo4w\usr\src\
     54    open c:\osgeo4w\usr\src\PDCurses-3.3\win32\mingwin32.mak
     55    at line 80 replace
     56{{{
     57-copy
     58}}}
     59 with
     60{{{
     61-cp
     62}}}
     63
     64    Run msys (from desktop icon) and at the prompt type:
     65
     66{{{
     67    cd /osgeo4w/usr/src/PDCurses-3.3/win32
     68    make
     69    install libcurses.a /osgeo4w/lib
     70    install pdcurses.dll /osgeo4w/bin
     71    cd ..
     72    install -m 644 curses.h /osgeo4w/include
     73}}}
     74
     75=== Zlib ===
     76
     77Download '''zlib'' from [http://www.zlib.net/zlib-1.2.3.tar.gz here]
     78
     79    Unpack to c:\osgeo4w\usr\src\
     80    Open c:\osgeo4w\usr\src\zlib-1.2.3\win32\Makefile.gcc
     81
     82    Replace line 102 with:
     83
     84{{{
     85    INCLUDE_PATH=/osgeo4w/include
     86    LIBRARY_PATH=/osgeo4w/lib
     87    SHARED_LIBRARY_PATH=/osgeo4w/bin
     88}}}
     89
     90    At lines 109-110 delete:
     91
     92{{{
     93    -@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH)
     94    -@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH)
     95}}}
     96
     97    After line 111 add:
     98
     99{{{
     100    -$(INSTALL) $(SHAREDLIB) $(SHARED_LIBRARY_PATH)
     101}}}
     102
     103    After line 118 add:
     104
     105{{{
     106    -$(RM) $(SHARED_LIBRARY_PATH)/$(SHAREDLIB)
     107}}}
     108
     109    Run msys (from desktop icon) and at the prompt type:
     110   
     111{{{
     112    cd /osgeo4w/usr/src/zlib-1.2.3
     113    make -f win32/Makefile.gcc
     114    make install -f win32/Makefile.gcc
     115}}}
     116
     117(As an aside, we could probably put the following files into a zlib-headers package:
     118    /osgeo4w/include/zlib.h
     119    /osgeo4w/include/zconf.h
     120    /osgeo4w/bin/zlib1.dll
     121    /osgeo4w/lib/libz.a
     122    /osgeo4w/lib/libzdll.a)
     123
     124=== Regex ===
     125
     126Download regex from [http://downloads.sourceforge.net/gnuwin32/regex-2.7-bin.zip here]
     127    Unpack to c:\osgeo4w
     128
     129=== Libjpeg ===
     130
     131Download libjpeg from [http://www.ijg.org/files/jpegsrc.v6b.tar.gz here]
     132    Unpack to c:\osgeo4w\usr\src
     133
     134    In MSYS console, type:
     135
     136{{{
     137cd /osgeo4w/usr/src/jpeg-6b
     138./configure --prefix=/osgeo4w --enable-shared
     139make
     140mkdir /osgeo4w/man/man1
     141make install
     142}}}
     143
     144Because make procedure doesn't create the shared library (even if enabled by configure), we need to build it manually:
     145(As a hint, you can copy the below and paste int msys with Shift+Insert)
     146{{{
     147COMOBJECTS="jcomapi.o jutils.o jerror.o jmemmgr.o jmemnobs.o"
     148CLIBOBJECTS="jcapimin.o jcapistd.o jctrans.o jcparam.o \
     149jdatadst.o jcinit.o jcmaster.o jcmarker.o jcmainct.o \
     150jcprepct.o jccoefct.o jccolor.o jcsample.o jchuff.o \
     151jcphuff.o jcdctmgr.o jfdctfst.o jfdctflt.o jfdctint.o"
     152DLIBOBJECTS="jdapimin.o jdapistd.o jdtrans.o jdatasrc.o \
     153jdmaster.o jdinput.o jdmarker.o jdhuff.o jdphuff.o \
     154jdmainct.o jdcoefct.o jdpostct.o jddctmgr.o \
     155jidctfst.o jidctflt.o jidctint.o jidctred.o \
     156jdsample.o jdcolor.o jquant1.o jquant2.o jdmerge.o"
     157LIBOBJECTS="$CLIBOBJECTS $DLIBOBJECTS $COMOBJECTS"
     158COBJECTS="cjpeg.o rdppm.o rdgif.o rdtarga.o rdrle.o rdbmp.o rdswitch.o cdjpeg.o"
     159DOBJECTS="djpeg.o wrppm.o wrgif.o wrtarga.o wrrle.o wrbmp.o rdcolmap.o cdjpeg.o"
     160TROBJECTS="jpegtran.o rdswitch.o cdjpeg.o transupp.o"
     161for i in *.exe ; do rm /osgeo4w/bin/$i ; done
     162rm *.exe
     163cd .libs
     164rm libjpeg.a
     165rm /osgeo4w/lib/libjpeg.a
     166cd ..
     167gcc -shared -s -o ./.libs/libjpeg.dll -lm -Wl,--out-implib,./.libs/libjpeg.a  $LIBOBJECTS
     168gcc -s -g -O2 -o cjpeg.exe $COBJECTS -L./.libs/ -ljpeg
     169gcc -s -g -O2 -o djpeg.exe $DOBJECTS -L./.libs/ -ljpeg
     170gcc -s -g -O2 -o jpegtran.exe $TROBJECTS -L./.libs/ -ljpeg
     171gcc -s -g -O2 -o rdjpgcom.exe rdjpgcom.o -L./.libs/ -ljpeg
     172gcc -s -g -O2 -o wrjpgcom.exe wrjpgcom.o -L./.libs/ -ljpeg
     173cd .libs
     174install libjpeg.a /osgeo4w/lib
     175install libjpeg.dll /osgeo4w/bin
     176cd ..
     177for i in *.exe ; do install $i /osgeo4w/bin ; done
     178}}}
     179
     180(Again as an aside, we could put the following into a jpeg-headers package (with proper attributes?):
     181    /osgeo4w/lib/libjpeg.a
     182    /osgeo4w/bin/libjpeg.dll
     183    /osgeo4w/bin/cjpeg.exe
     184    /osgeo4w/bin/djpeg.exe
     185    /osgeo4w/bin/jpegtran.exe
     186    /osgeo4w/bin/rdjpgcom.exe
     187    /osgeo4w/bin/wrjpgcom.exe)
     188
     189=== PostgreSQL ===
     190
     191Download pgsql from [http://ftp2.it.postgresql.org/mirrors/postgres/source/v8.3.1/postgresql-8.3.6.tar.gz here]
     192    Unpack to c:\osgeo4w
     193    open c:\osgeo4w\postgresql-8.3.6\src\test\regress\pg_regress.c
     194    At line 51
     195    change:
     196    char           *bindir = PGBINDIR;
     197    char           *libdir = LIBDIR;
     198    char           *datadir = PGSHAREDIR;
     199
     200    to:
     201    char           *bindir = "/osgeo4w/apps/pgsql/bin";
     202    char           *libdir = "/osgeo4w/apps/pgsql/lib";
     203    char           *datadir = "/osgeo4w/apps/pgsql/share";
     204       
     205    In msys console type:
     206
     207{{{
     208cd /osgeo4w/postgresql-8.3.6
     209./configure --prefix=/osgeo4w/apps/pgsql \
     210--with-includes=/osgeo4w/include \
     211--with-libraries=/osgeo4w/lib \
     212--without-readline
     213make -f GNUmakefile
     214make install -f GNUmakefile
     215}}}
     216
     217=== SQLite ===
     218Download '''sqlite3''' from [http://www.sqlite.org/sqlite-amalgamation-3.5.9.tar.gz here]
     219    Unpack to c:\osgeo4w\usr\src
     220
     221{{{
     222./configure --prefix=/osgeo4w/apps/sqlite
     223make
     224make install
     225}}}
     226
     227=== GDAL ===
     228
     229'''Untested'''
     230
     231Get gdal <http://download.osgeo.org/gdal/gdal-1.5.2.tar.gz>
     232    Unpack to c:\osgeo4w\usr\src
     233    Open c:\osgeo4w\usr\src\gdal-1.5.2\configure
     234    At line 23832 replace:
     235
     236{{{
     237expat_lib_flags="-L$expat_prefix/lib -lexpat"
     238}}}
     239    with:
     240{{{
     241LIBS="$LIBS -L$expat_prefix/lib -lexpat"
     242}}}
     243
     244    In MSYS console, type:
     245{{{
     246cd /usr/local/src/gdal-1.5.2
     247./configure --prefix=/osego4w \
     248--without-grass \
     249--with-sqlite3=/osgeo4w/apps/sqlite \
     250--with-pg=/osgeo4w/apps/pgsql/bin/pg_config.exe
     251}}}     
     252    Open c:\msys\local\src\gdal-1.5.2\GNUmakefile
     253    After line 4 add:
     254{{{
     255    GDAL_ROOT=.
     256}}}
     257    Finally build and install GDAL:
     258{{{
     259make -f GNUmakefile
     260make install -f GNUmakefile
     261}}}
     262
     263=== Tcl/Tk (skip if only compiling grass7) ===
     264
     265'''Untested'''
     266
     267Download Tcl from [http://prdownloads.sourceforge.net/tcl/tcl8.5.2-src.tar.gz here]
     268Download Tk from [http://prdownloads.sourceforge.net/tcl/tk8.5.2-src.tar.gz here]
     269    Unpack both to c:\osgeo4w\usr\src
     270    In the msys console type:
     271{{{
     272cd /osgeo4w/usr/src/tcl8.5.2/win
     273./configure --prefix=/osgeo4w/apps/tcl-tk --enable-shared
     274make
     275make install
     276cd /osgeo4w/apps/tcl-tk/bin
     277mv tclsh85.exe tclsh.exe
     278cd /osgeo4w/usr/src/tk8.5.2/win
     279./configure --prefix=/osgeo4w/apps/tcl-tk --with-tcl=/osgeo4w/usr/src/tcl8.5.2/win --enable-shared
     280make
     281make install
     282cd /osgeo4w/apps/tcl-tk/bin
     283mv wish85.exe wish.exe
    53284
    54285=== Compiling and Installing GRASS (6.4.0) ===
    55286
    56287 * Download the latest GRASS 6.4.0 source code from [http://grass.osgeo.org/grass64/source/snapshot/ here].
    57  * Unpack to c:\msys\local\src  (create these folders first)
     288 * Unpack to c:\osgeo4w\usr\src
     289 * Download the installer script '''package.sh''' from [http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/mswindows/osgeo4w/package.sh?format=raw here] and put in c:\osgeo4w\usr\src\grass-6.4xxx
     290 * Open package.sh and at line 12:
     291Change:
     292{{{
     293--with-libs="/c/OSGeo4W/lib /c/MinGW/lib" \
     294--with-includes="/c/OSGeo4W/include /c/MinGW/include" \
     295}}}
     296to:
     297{{{
     298--with-libs=/c/OSGeo4W/lib \
     299--with-includes=/c/OSGeo4W/include \
     300}}}
    58301
    59302To compile, type in MSYS console:
    60303
    61 ''Note: this needs to be updated, see also grass64/mswindows/osgeo4w/[source:grass/branches/develbranch_6/mswindows/osgeo4w/package.sh package.sh]''
    62 {{{
    63 cd /usr/local/src/grass-6.4.svn_src_snapshot_2009_03_07
    64 ./configure \
    65 --prefix=/usr/local \
    66 --with-includes=/usr/local/include \
    67 --with-libs=/usr/local/lib \
    68 --disable-x11 \
    69 --without-x \
    70 --with-cxx \
    71 --enable-shared \
    72 --enable-largefile \
    73 --with-opengl=windows \
    74 --with-fftw \
    75 --with-freetype \
    76 --with-proj-share=/usr/local/share/proj \
    77 --with-gdal=/usr/local/bin/gdal-config \
    78 --with-tcltk --with-tcltk-includes=/usr/local/tcl-tk/include --with-tcltk-libs=/usr/local/tcl-tk/bin \
    79 --with-sqlite --with-sqlite-includes=/usr/local/sqlite/include --with-sqlite-libs=/usr/local/sqlite/lib \
    80 --with-postgres --with-postgres-includes=/usr/local/pgsql/include --with-postgres-libs=/usr/local/pgsql/lib
    81 }}}
    82 
    83 When finished, you should have the following screen output:
    84 
    85 {{{
    86 GRASS is now configured for:  i686-pc-mingw32
    87 
    88  Source directory:            /usr/local/src/grass-6.4.0
    89  Build directory:             /usr/local/src/grass-6.4.0
    90  Installation directory:      ${prefix}/grass-6.4.0
    91  Startup script in directory: ${exec_prefix}/bin
    92  C compiler:                  gcc -g -O2
    93  C++ compiler:                c++ -g -O2
    94  Building shared libraries:   yes
    95  64bit support:               no
    96  OpenGL platform:             Windows
    97 
    98   NVIZ:                       yes
    99 
    100   BLAS support:               no
    101   C++ support:                yes
    102   DWG support:                no
    103   FFMPEG support:             no
    104   FFTW support:               yes
    105   FreeType support:           yes
    106   GDAL support:               yes
    107   GLw support:                no
    108   JPEG support:               yes
    109   LAPACK support:             no
    110   Large File Support (LFS):   yes
    111   Motif support:              no
    112   MySQL support:              no
    113   NLS support:                no
    114   ODBC support:               no
    115   OGR support:                yes
    116   OpenGL support:             yes
    117   PNG support:                yes
    118   PostgreSQL support:         yes
    119   Python support:             no
    120   Readline support:           no
    121   SQLite support:             yes
    122   Tcl/Tk support:             yes
    123   wxWidgets support:          no
    124   TIFF support:               yes
    125   X11 support:                no
    126   MacOSX application:         no
    127 }}}
    128 
    129 Having GRASS successfully configured, now you can compile it:
    130 
    131 {{{
    132 export PATH="/usr/local/bin:/usr/local/tcl-tk/bin:/usr/local/sqlite/bin:/usr/local/pgsql/lib:$PATH"
    133 make
    134 }}}
    135 
    136 When finished, you should have the following compilation log:
     304{{{
     305export PATH="/osgeo4w/bin:/osgeo4w/apps/tcl-tk/bin:/osgeo4w/apps/sqlite/bin:/osgeo4w/apps/pgsql/lib:$PATH"
     306cd /osgeo4w/usr/src/grass-6.4xxx (change to dir of the version you downloaded)
     307package.sh
     308}}}
     309
     310When finished, you should have the following compilation log (c:\osgeo4w\usr\src\grass-6.4xxx\error.log):
    137311
    138312{{{
     
    169343Currently r.li.* cannot be compiled on Windows.
    170344
    171 The best way to check details, is to open c:\msys\local\src\grass-6.4.0\error.log using your favourite web client/editor.
    172 
    173 '''Installation'''
    174 
    175 Then install GRASS:
    176 
    177     make install
    178 
    179 Now GRASS should be installed in c:\msys\local\grass-6.4.0\
     345Now GRASS should be installed in c:\osgeo4w\apps\grass-6.4.0\
    180346
    181347'''Usage'''
    182348
    183 The startup grass64.bat file should be in c:\msys\local\bin\grass64.bat
    184 
    185 If using the grass64.sh instead, add to that file:
    186 {{{
     349The startup '''grass64.bat''' file should be in C:\OSGeo4W\apps\grass\bin
     350Open it and replace the contents with:
     351{{{
     352@echo off
     353SET OSGEO4W_ROOT=C:\OSGeo4W
     354PATH %OSGEO4W_ROOT%\bin;%PATH%
     355for %%f in ("%OSGEO4W_ROOT%"\etc\ini\*.bat) do call "%%f"
     356
     357rem #########################################################################
     358rem #
     359rem #           GRASS Initialization
     360rem #
     361rem #########################################################################
     362
     363set WINGISBASE=%OSGEO4W_ROOT%/apps/grass/grass-6.4xxx (change to the appropriate grass version)
     364"%WINGISBASE%"\etc\init.bat %*
     365}}}
     366
     367If you want to be able to use the console from within grass, you'll need a different startup file:
     368Create '''C:\OSGeo4W\apps\grass\bin\grass64''' with the following contents:
     369{{{
     370#! /bin/sh
     371#############################################################################
     372#
     373# MODULE:       GRASS Initialization
     374# AUTHOR(S):    Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th
     375# PURPOSE:      The source file for this shell script is in
     376#               lib/init/grass.src and is the grass startup script. It
     377#               requires a source file because the definition of GISBASE
     378#               is not known until compile time and is substituted from the
     379#               Makefile. Any command line options are passed to Init.sh.
     380# COPYRIGHT:    (C) 2000-2005 by the GRASS Development Team
     381#
     382#               This program is free software under the GNU General Public
     383#               License (>=v2). Read the file COPYING that comes with GRASS
     384#               for details.
     385#
     386#############################################################################
     387
     388trap "echo 'User break!' ; exit" 2 3 9 15
     389
     390# Set the GISBASE variable
     391GISBASE=/c/OSGeo4W/apps/grass/grass-6.4xxx (change to the appropriate grass version)
     392export GISBASE
     393
     394# Set the PATH variable
     395PATH="/osgeo4w/apps/tcl-tk/bin:/osgeo4w/apps/sqlite/bin:/osgeo4w/apps/pgsql/lib:$PATH"
     396export PATH
     397
    187398# Set the PYTHONPATH
    188399PYTHONPATH="$GISBASE/etc/python:$PYTHONPATH"
    189 }}}
    190 
    191 See also: grass64/mswindows/osgeo4w/package.sh for a scripted approach in the OSGeo4W environment.
     400
     401exec "$GISBASE/etc/Init.sh" "$@"
     402}}}
    192403
    193404=== TODO ===
    194405
    195406Describe installations of:
    196  * GDAL-GRASS-plugin
    197  * SQLite
    198  * PostgreSQL
    199  * Freetype ?
    200  * FFTW
     407 * other deps?
    201408
    202409== Building with MS Visual Studio ==