Changes between Version 82 and Version 83 of UsersWikiWinCompile


Ignore:
Timestamp:
11/23/09 16:22:16 (15 years ago)
Author:
pramsey
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UsersWikiWinCompile

    v82 v83  
    11= Compiling PostGIS 1.4 and 1.5 under Windows using MinGW/Msys =
    22
    3 A step by step guide how I managed to compile Postgis in windows XP SP3[[BR]]
    4 This guide assumes that you already have a postgresql-installation on your computer.[[BR]]
    5 You will have to compile postgresql here too, but that is just for the process of compiling postgis.
    6 
    7 '''I have used this install directories''':
     3A step by step guide to compiling PostGIS in windows XP SP3. This guide assumes that you already have a PostgreSQL installation on your computer. You will have to compile PostgreSQL here too, but that is just for the process of compiling PostGIS.
     4
     5== Install Directories ==
     6
     7We have used the following install directories:
    88
    99MinGW: c:\MinGW[[BR]]
     
    1212installdirectory for postgresql: c:\postgresql
    1313
    14 a good tool for extracting tar-files is 7-zip from http://www.7-zip.org
    15 
    16 '''1. Installing Minimalist GNU for Windows (MinGW)'''
    17 
    18 Download Automated MinGW Installer  (Current - MinGW-5.1.4) from http://sourceforge.net/project/showfiles.php?group_id=2435
    19 
    20 (http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/MinGW-5.1.4.exe/download)
    21      1. Run the setup file and choose everything (except possibly Ada)
    22      2. Accept the default Install location of C:\MinGW
     14== Useful Utilities ==
     15
     16A good tool for extracting tar-files is 7-zip from http://www.7-zip.org
     17
     18== 1. Installing Minimalist GNU for Windows (MinGW) ==
     19
     20Download Automated MinGW Installer  (Current - MinGW-5.1.4) from http://sourceforge.net/project/showfiles.php?group_id=2435 (http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/MinGW-5.1.4.exe/download)
     21
     22 1. Run the setup file and choose everything (except possibly Ada)
     23 2. Accept the default Install location of C:\MinGW
    2324 
    24 '''2. Installing Minimal System (Msys)'''
    25 
    26 Msys provides you with a unix shell environment for compiling code under windows[[BR]]
    27 Download Msys http://sourceforge.net/projects/mingw/files/MSYS%20Base%20System/MSYS-1.0.11-rc-1.exe/download
    28 
    29 (this is listed in http://sourceforge.net/project/showfiles.php?group_id=2435)
    30 
    31      1. Say y to post Installation
    32      2. When prompted do you have MinGW -> y
    33      3. When prompted for where it is type -> C:\MinGW
    34  
    35  
    36 '''3. Installing Msy Development Toolkit'''
     25== 2. Installing Minimal System (MSYS) ==
     26
     27MSYS provides you with a unix shell environment for compiling code under windows.
     28
     29Download MSYS version 1.0.11. http://sourceforge.net/projects/mingw/files/MSYS%20Base%20System/MSYS-1.0.11-rc-1.exe/download (this is listed in http://sourceforge.net/project/showfiles.php?group_id=2435)
     30
     31 1. Say y to post Installation
     32 2. When prompted do you have MinGW -> y
     33 3. When prompted for where it is type -> C:\MinGW
     34   
     35== 3. Installing Msy Development Toolkit ==
    3736
    3837Download the MysDTK1.0.1 from http://downloads.sourceforge.net/mingw/msysDTK-1.0.1.exe
     38
    3939     1. Run the EXE install and accept all the defaults
    4040 
    41 '''4. MSYS Core 1.0.11''' (note you do not need this if you installed MSYS-1.0.11.exe)
    42 
    43      1. Download  MSYS Core 1.0.11 from http://downloads.sourceforge.net/mingw/msysCORE-1.0.11-2007.01.19-1.tar.bz2
    44      2. untar them and copy all content to c:\msys\1.0 and and click ok to overwrite existing files and folders.
    45      
    46 '''5. Download and install the following from gnuwin32.sourceforge.net/packages.html'''
    47 
    48 (Make sure to Change install directory to c:\mingw)
    49      1. Bison, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/bison-2.1.exe
    50      2. zlib, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/zlib-1.2.3.exe
    51      3. Flex, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/flex-2.5.4a-1.exe
    52      4. !GetText, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/gettext-0.14.4.exe
    53 
    54 '''Note for iconv we are going to compile our own instead of install from gnuwin since gnuwin changed some constants'''
    55      5. !LibIconv
    56          a. download source from http://ftp.gnu.org/gnu/libiconv (we are going to use libiconv-1.13.1.tar.gz)
    57          b. gzip -d -c libiconv-1.13.1.tar.gz | tar xvf -
    58          c. cd libiconv-1.13.1
    59          d. ./configure --prefix=/c/mingw
    60          e. make && make install
    61          f.  verify you are running the latest with --  iconv --version
    62 
    63 
    64 '''6. update m4'''[[BR]]
    65      1. download from: http://downloads.sourceforge.net/mingw/m4-1.4.7-MSYS.tar.bz2
    66      2. untar and copy the m4.exe-file in the end of the path to C:\msys\1.0\bin
    67 
    68 
    69 '''7. Update environment variable'''
    70 
    71 The below is copied direct from http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite
    72 ----
    73 Environment Settings[[BR]]
    74 When you install command line tools, such as MinGW, or !GnuWin32 tools, you have to tell the command line interpreter where to find them; this is usually accomplished by adding the appropriate directory names to the PATH variable in your environment. Typically, it is your responsibility to do this; please do not expect the installer, (if you used one), to do it for you.[[BR]]
    75 Warning: Adding entries to the PATH is normally benign. However, if you delete, you may mess up your PATH string, and you could seriously compromise the functioning of your computer. Please be careful.[[BR]]
     41== 4. Installing GNUWin Support Packages ==
     42
     43Download and install the following from gnuwin32.sourceforge.net/packages.html
     44
     45 1. Bison, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/bison-2.1.exe
     46 2. zlib, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/zlib-1.2.3.exe
     47 3. Flex, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/flex-2.5.4a-1.exe
     48 4. !GetText, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/gettext-0.14.4.exe
     49 5. Zip, http://kent.dl.sourceforge.net/sourceforge/gnuwin32/zip-3.0-setup.exe
     50
     51Run each file and be sure to change the install directory to c:\MinGW
     52
     53== 5. Installing LibIconf ==
     54
     55For iconv we are going to compile our own instead of install from GNUWin since GNUWin changed some constants.
     56
     57  1. download source from http://ftp.gnu.org/gnu/libiconv (we are going to use libiconv-1.13.1.tar.gz)
     58  2. gzip -d -c libiconv-1.13.1.tar.gz | tar xvf -
     59  3. cd libiconv-1.13.1
     60  4. ./configure --prefix=/c/mingw
     61  5. make && make install
     62  6.  verify you are running the latest with --  iconv --version
     63
     64== 6. Update m4 ==
     65
     66 1. download from: http://downloads.sourceforge.net/mingw/m4-1.4.7-MSYS.tar.bz2
     67 2. untar and copy the m4.exe-file in the end of the path to C:\msys\1.0\bin
     68
     69== 7. Update environment variables ==
     70
     71The below is copied direct from http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite#toc33
     72
     73  ''Environment Settings''
     74
     75  When you install command line tools, such as MinGW, or !GnuWin32 tools, you have to tell the command line interpreter where to find them; this is usually accomplished by adding the appropriate directory names to the PATH variable in your environment. Typically, it is your responsibility to do this; please do not expect the installer, (if you used one), to do it for you.
     76
     77  Warning: Adding entries to the PATH is normally benign. However, if you delete, you may mess up your PATH string, and you could seriously compromise the functioning of your computer. Please be careful.[[BR]]
    7678
    7779   1. Right-click on "My Computer" and select "Properties".
     
    8183   5. Scroll to the end of the string and at the end add ";<installation-directory>\bin". Here <installation-directory> is the full absolute path name of the installation directory; if you accepted the defaults when installing tar and gzip, then for these, it will (probably) be C:\Program Files\!GnuWin32, while for MinGW it will be C:\MinGW\bin, (if you kept to the recommended default installation directory). Don't forget the semicolon; this separates the entries in the PATH.
    8284   6. press OK -> OK -> OK and you are done.
    83 ----
     85
    8486Set the environment variable HOME to C:\msys\1.0\home
    8587
    86 '''8. Installing Autoconf, Automake and Libtool'''
     88== 8. Installing Autoconf, Automake and Libtool ==
    8789
    8890Download the sourcecode of:
     
    9294    3. libtool  from ftp.gnu.org/gnu/libtool
    9395
    94 The latest releases 2009-04-11 is:
    95 
    96  * autoconf 2.63 (1.4MB)
    97  * automake 1.10.2 (1.2MB)
     96The latest releases 2009-11-11 are:
     97
     98 * autoconf 2.65 (1.4MB)
     99 * automake 1.11.1 (1.2MB)
    98100 * libtool  2.2.4 (1.8MB)
    99101
    100 make a folder c:\thesrc and untar the source-files there
    101 
    102 '''Launch MSys from Start->Programs->MinGW->msys'''
    103 
    104 You now get a terminal-window that understands a bunch of unix/linux-commands (at least enough for compiling)[[BR]]
    105 print:
    106        1. ''cd /c/thesrc''
    107        2. ''ls''
    108 Now you will get the folders you have copied to the directory listed.[[BR]]
    109 The names of the folders will be different than in this example if you have newer releases of the tools.[[BR]]
    110 move into one of the folders:
    111        3. ''cd autoconf-2.63''
    112  
    113 ok, now we are in the directory with the autoconf source-code[[BR]]
    114 print:[[BR]]
    115 ''ls''[[BR]]
    116 if you just see a new folder called autoconf-2.63 you have to go into that one to:[[BR]]
    117 ''cd autoconf-2.63''[[BR]]
    118 when you se a lot of folders like bin and lib and a lot of files, then you are right[[BR]]
    119 now we shall configure and make this tool[[BR]]
    120 print:
    121       4. ''configure --prefix=/c/mingw && make && make install''
    122 now a lot of text shall appear in the window and after a while you will hopefully get no error-messages but jut get back to your prompt.[[BR]]
    123 
    124 To verify you are not running autoconf-2.63 do the following:
    125 
    126 autoconf --version
    127 
     102Make a folder c:\thesrc and untar the source-files there.
     103
     104Launch MSys from Start->Programs->MinGW->msys or from the desktop MSYS icon.
     105
     106You now get a terminal-window that understands a bunch of unix/linux-commands (at least enough for compiling)
     107{{{
     108# cd /c/thesrc
     109# ls
     110}}}
     111Now you will get the folders you have copied to the directory listed. The names of the folders will be different than in this example if you have newer releases of the tools. Configure, compile and install autoconf.
     112{{{
     113# cd autoconf-2.65
     114# ./configure --prefix=/c/mingw
     115# make
     116# make install
     117# autoconf --version
     118}}}
    128119If it says you are running lower than 2.63, most likely you have another one installed in addition.  Running the below will tell you which one it is picking up.
    129 
     120{{
    130121which autoconf
    131 
    132 now go to the other source-code directories and do the same[[BR]]
    133       5. ''cd ..'' (backing to the directory c:\thesrc)
    134       6. ''cd automake-1.10.2''
    135       7. ''configure --prefix=/c/mingw && make && make install''
    136 
    137       8. ''cd ..'' (backing to the directory c:\thesrc)
    138       9. ''cd libtool-2.2.4''
    139       10. ''configure --prefix=/c/mingw && make && make install''
     122}}}
     123Now configure, compile and install automake.
     124{{{
     125# cd automake-1.11
     126# ./configure --prefix=/c/mingw
     127# make
     128# make install
     129}}}
     130Now configure, compile and install automake.
     131{{{
     132# cd libtool-2.2.4
     133# ./configure --prefix=/c/mingw
     134# make
     135# make install
     136}}}
    140137 
    141 '''9. Compiling PostgreSQL'''[[BR]]   
    142 Download latest PostgreSQL source from http://www.postgresql.org/ftp/source/ and untar in C:\thesrc[[BR]]
    143 move to folder[[BR]]
    144       1. ''cd /c/thesrc/postgresql-8.3.7'' (the version of today)
    145       2. ''configure --prefix=/c/postgres && make && make install''
    146       3.  If you want to be able to do a full make check on PostGIS, [UsersWikiWinCompileInitdb Initialize the postgresql database cluster]
     138== 9. Compiling PostgreSQL ==
     139
     140Download latest [http://www.postgresql.org/ftp/source/ PostgreSQL source] and untar in C:\thesrc
     141{{{
     142# tar xvfz postgresql-8.4.1.tar.gz
     143# cd postgresql-8.4.1
     144# ./configure --prefix=/c/postgres
     145# make
     146# make install
     147}}}
     148If you want to be able to do a full make check on PostGIS, [UsersWikiWinCompileInitdb Initialize the postgresql database cluster] first.
    147149   
    148 note that we now have changed the install-directory from mingw to postgres
    149 
    150 if you get an error something like:[[BR]]
    151 e:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sspi.h:60: error: syntax error before SECURITY_STRING[[BR]]
    152 In file included from e:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/security.h:39, [[BR]]
    153 from libpq-int.h:57, [[BR]]
    154 from fe-auth.h:18, [[BR]]
    155 from fe-auth.c:48: [[BR]]
     150Note that we now have changed the install-directory from /c/MingW to /c/postgres.
     151
     152=== PostgreSQL 8.3 ===
     153
     154If you are compiling PostgreSQL 8.3 and you get a compilation error like this:
     155{{{
     156e:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sspi.h:60: error: syntax error before SECURITY_STRING
     157In file included from e:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/security.h:39,
     158from libpq-int.h:57,
     159from fe-auth.h:18,
     160from fe-auth.c:48:
    156161e:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/ntsecpkg.h:123: error: syntax error before SECURITY_STRING
    157 
    158 the solution is to edit two of the source-files.[[BR]]
    159 In both files: [[BR]]
    160 postgresql-8.3.7/src/include/libpq/libpq-be.h [[BR]]
    161 and [[BR]]
    162 postgresql-8.3.7/src/interfaces/libpq/libpq-int.h:
    163 
    164 add a new include-file:[[BR]]
    165 #ifdef ENABLE_SSPI[[BR]]
    166 #define SECURITY_WIN32[[BR]]
    167 #include <ntsecapi.h> '''<- Add this include'''[[BR]]
    168 #include <security.h>[[BR]]
    169 #undef SECURITY_WIN32[[BR]]
    170 
    171 you can read about this here:[[BR]]
    172 http://pgolub.wordpress.com/2008/12/15/building-postgresql-client-library-using-mingw-under-winxp-sp3/ [[BR]]
    173 and[[BR]]
    174 http://postgresqlorg.blogspot.com/2008/09/hackers-83-4-vista-mingw-initdb.html [[BR]]
    175 
    176 '''10. Compiling GEOS'''[[BR]]
    177 Download latest GEOS-source from trac.osgeo.org/geos/ ( http://download.osgeo.org/geos/geos-3.1.1.tar.bz2 )
    178 and copy into C:\thesrc
    179 
    180 Extract with:
    181 cd /thesrc
    182 
    183 bzip2 -d -c geos-3.1.1.tar.bz2 | tar -xvf -
    184 
    185 
    186 Do the same as with postgresql, extract to c:\thesrc [[BR]]
    187 in msys terminal move to the GEOS source-code directory[[BR]]
    188      1. ''configure --prefix=/c/postgres && make && make install''
    189      2. To strip all the debug info weight from the libgeos-3-1-1.dll run
    190 
    191           strip /c/postgres/bin/libgeos-3-1-1.dll
    192 
    193 NOTE: If you are compiling the latest GEOS 3.2 (geos/trunk, you may get an error because of a bug in MingW). GEOS 3.2 is needed
    194 to take advantage of the new ST_Buffer enhancements in PostGIS 1.5+ and also some fixes for topology exceptions in intersects and intersection.
    195 
    196 I had to comment out like below -- change lines (159, 166) to below (in C:\MinGW\include\c++\3.4.5\cwchar  (same issue exists under gcc 4.4.0) 
     162}}}
     163The solution is to edit two of the PostgreSQL source files, src/include/libpq/libpq-be.h and src/interfaces/libpq/libpq-int.h, and add a new line in them in the ENABLE_SSPI block:
     164{{{
     165#ifdef ENABLE_SSPI
     166#define SECURITY_WIN32
     167#include <ntsecapi.h> <- Add this include line
     168#include <security.h>
     169#undef SECURITY_WIN32
     170}}}
     171You can read about this issue [http://pgolub.wordpress.com/2008/12/15/building-postgresql-client-library-using-mingw-under-winxp-sp3/ here] and
     172[http://postgresqlorg.blogspot.com/2008/09/hackers-83-4-vista-mingw-initdb.html here].
     173
     174=== PostgreSQL 8.4 ===
     175
     176The above problem has been fixed in PostgreSQL 8.4.
     177
     178== 10. Compiling GEOS ==
     179
     180Download latest GEOS source from http://trac.osgeo.org/geos/ either the [http://download.osgeo.org/geos/geos-3.1.1.tar.bz2 3.1.1 version] or the [http://download.osgeo.org/geos/geos-svn.tar.bz2 3.2SVN version].
     181{{{
     182# bzip2 -d -c geos-svn.tar.bz2 | tar xvf -
     183# ./configure --prefix=/c/postgres
     184# make
     185# make install
     186}}}
     187To strip all the debug info weight from the libgeos DLL files, run
     188{{{
     189# strip /c/postgres/bin/libgeos-3-2-0.dll
     190}}}
     191
     192=== GEOS 3.2 ===
     193
     194If you are compiling the latest GEOS 3.2 (the SVN version), you may get an error because of a bug in MinGW. GEOS 3.2 is needed to take advantage of the new ST_Buffer enhancements in PostGIS 1.5+ and also some fixes for topology exceptions in intersects and intersection.
     195
     196I had to comment out the lines as seen below, lines 159 and 166 in C:\MinGW\include\c++\3.4.5\cwchar (the same issue still exists under gcc 4.4.0)
     197{{{
    197198  //using ::swprintf; 
    198 
    199199  //using ::vswprintf;
    200 
    201 refer to [http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435]
    202 and [http://lists.osgeo.org/pipermail/geos-devel/2009-June/004240.html] for details
    203 
    204 If you are runnning gcc 4.4.0 and you get complaints about link g++ you probably need to do this too:
    205 
    206 and changing library_names='libstdc++.dll.a'
    207 
     200}}}
     201Refer to this [http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435 MinGW bug ticket] and [http://lists.osgeo.org/pipermail/geos-devel/2009-June/004240.htm mailing list entry] for more details.
     202
     203If you are runnning gcc 4.4.0 and you get complaints about link g++ you probably need to do this too. Change
     204{{{
     205library_names='libstdc++.dll.a'
     206}}}
    208207to
     208{{{
    209209#library_names='libstdc++.dll.a'
    210 
    211210library_names='libstdc++.a'
    212 
    213 As alluded to here http://www.nabble.com/GCC-4.4.0-fails-with-GMP-td24191439.html
    214 
    215 
    216 '''11. Compiling Proj'''[[BR]]
    217 Download latest Proj from trac.osgeo.org/proj/ (http://download.osgeo.org/proj/proj-4.6.1.zip ) [[BR]]
    218 in msys terminal move to the Proj source-code directory[[BR]]
    219      1. ''./configure --prefix=/c/postgres --enable-shared --disable-static ''
    220      2. ''make && make install''
    221 --Make the libproj.dll and make it dynamically linked
    222      3. cd /c/postgres/lib
    223      4. gcc -shared -o libproj.dll -Wl,--out-implib=libproj.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive libproj.a -Wl,--no-whole-archive /c/mingw/lib/libmingw32.a
    224 
    225 
    226 '''12. Installing C-Unit -- needed for PostGIS 1.4 and above make check'''
     211}}}
     212As alluded to [http://www.nabble.com/GCC-4.4.0-fails-with-GMP-td24191439.html here].
     213
     214== 11. Compiling Proj4 ==
     215
     216Download [http://trac.osgeo.org/proj/ the latest Proj4 from the web site, and the datum shifts grid file.
     217
     218 * http://download.osgeo.org/proj/proj-4.7.0.tar.gz
     219 * http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
     220
     221The datum grid file must be unzipped into the "nad" subdirectory of the Proj4 source tree.
     222
     223{{{
     224# tar xvfz proj-4.7.0.tar.gz
     225# cd proj-4.7.0
     226# cd nad
     227# unzip ../../proj-datumgrid-1.5.zip
     228# cd ..
     229# ./configure --prefix=/c/postgres --enable-shared --disable-static --without-mutex
     230# make
     231# make install
     232}}}
     233Make the libproj.dll and make it dynamically linked
     234{{{
     235# cd /c/postgres/lib
     236# gcc -shared -o libproj.dll -Wl,--out-implib=libproj.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive libproj.a -Wl,--no-whole-archive /c/mingw/lib/libmingw32.a
     237}}}
     238
     239== 12. Installing C-Unit ==
     240
     241C-Unit is a testing framework, and is needed by PostGIS 1.4 and above to run the "make check" testing step.
     242
    227243      1. download http://sourceforge.net/projects/cunit/files/CUnit/CUnit-2.1-0-winlib.zip
    228244      2. extract and copy contents to C:\MingW