== Compiling using Mingw64-w64, Mingw64-w32 for 64-bit/32-bit (work in Progress) == [wiki:UsersWikiWinCompile Back to Compiling in Windows] There are issues with GEOS compile above 4.5.4 or so, in 4.6.1+, the make check crashes and so does PostGIS tests when compiled with GCC 4.6+. That said you should pick a build lower than GCC 4.6. We like GCC 4.5.4 Issues are documented in http://trac.osgeo.org/geos/ticket/518 (also similar issue compiling Geos under windows 64-bit SDK http://trac.osgeo.org/geos/ticket/528 ) Also note, the mingw64 for build 32-bit binaries only works for PostgreSQL 9.2+. There are changes they did in 9.2 that were never backported to 9.1 and below. So to compile PostGIS for 32-bit for 9.1 and below you need to use the regular old Msys instructions. mingw64 chain will work for 64-bit 9.0-9.3 and for 32-bit 9.2-9.3. If you want to get to the last step fast to immediately start compiling PostGIS without having to compile the dependencies, you can download our prepared mingw64 bit chains which you can download from [http://www.bostongis.com/postgisstuff/ming64.zip] and for 32-bit (for PostgreSQL 9.2+) [http://www.bostongis.com/postgisstuff/ming32.zip] == 1. Installing Minimalist GNU for Windows-w64 (MinGW-w64) == We will use MingGW-w64 toolchain instead of the standard MingW since it has support for both 32-bit and 64-bit compiling. For this discussion we are using the binaries built for running on Windows. We haven't tried the builds designed for building windows binaries under Linux/Unix. Details of the prefixes of files can be found at [http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure What to download] MingW-w64 site is [http://mingw-w64.sourceforge.net] * If you are building for 64-bit Windows download the personal build from [http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/sezero_4.5_20111101/] with name starting with '''mingw-w64-bin_x86_64-mingw_20111101_sezero.zip''' * If you are building for 32-bit Windows download one of the binary packages from [http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/sezero_4.5_20111101/] with name starting with '''mingw-w32-bin_i686-mingw_20111101_sezero.zip''' * Extract your respective zip into a folder called C:\ming64\mingw64 or c:\ming32\mingw32 * Download the latest patch in same folder e.g. sezero_20111101-w32-update-rev.5151.zip for win32, sezero_20111101-w64-update-rev.5151.zip for win64 and extract into same respective folders. /** NOTE to self: This may not be necessary anymore **/ GEOS fails to link if it picks up 32-bit dlls so to overcome this, I copied over the dlls from windows/sytem32 and renamed them as described in #linking errors seems to be caused by as described here [http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw64_how_to.html#env] mingw64 is picking up the 32-bit dlls from syswow64 instead of the 64-bit dlls from windows/system32 I only needed to copy ws2_32.dll for geos to compile without errors Others may be needed not sure. with windows explorer copy the files from windows/system32 {{{ ws2_32.dll }}} To your folder: C:\ming64\x86_64-w64-mingw32\lib and then rename them adding a lib extensions so you have {{{ libws2_32.dll # these ones didn't seem necessary for PostGIS: libmsimg32.dll,libgdi32.dll, libcrypt32.dll and libwldap32.dll }}} == prefixed files == These sometimes exist only with the prefixes and cause issues during compilation so you'll need prefixless versions {{{ cp /mingw/bin/x86_64-w64-mingw32-cpp.exe /mingw/bin/cpp.exe cp /mingw/bin/x86_64-w64-mingw32-strip.exe /mingw/bin/strip.exe }}} == 2. Installing Msys == MSys is 32-bit but you can use it with your 32-bit or 64-bit mingw-w64. Instructions are here [http://sourceforge.net/apps/trac/mingw-w64/wiki/MSYS mingw-w64 with MSYS] and repeated here for completeness * download [http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/ Msys] MSYS-20110309.zip (update there is now a newer MSYS -- MSYS-20110526.zip) * Extract into a folder called C:\Ming64\msys (or C:\Ming32\msys) * launch msys.bat * type {{{ sh /postinstall/pi.sh }}} When prompted type in {{{C:/ming64/mingw64}}} or {{{C:/ming32/mingw32}}} depending on which tool chain you chose Once done, type logout and the console should exit. Note: You can have both if you are using windows 64-bit and we do. GEOS also gives missing vtable message during link. I think this was caused by msys missing find.exe, so I copied the find.exe from regular msys package ( as instructed in the [http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw64_how_to.html#env] to bin of respective ming64/ming32 msys folders. == 3a. Installing Autoconf, Automake and Libtool == Relaunch C:\ming64\msys\msys.bat (or c:\ming32\msys\msys.bat) We create a file with commands like this and make sure this is included in all my compile scripts {{{ #if you are building for 32-bit change ming64 to ming32 export PROJECTS=/c/ming64/projects #for a 64-bit build export MINGHOST=x86_64-w64-mingw32 #if you are building for 32-bit change to this #export MINGHOST=i686-w64-mingw32 #this part is not necessary #but we like to prefix our binary folders with #version export OS_BUILD=64 #change to 32 if building for 32 }}} {{{ #if you are building for 32-bit change ming64 to ming32 mkdir ${PROJECTS} }}} Verify which versions of these you have with autoconf --version etc. If they are not newer (or you get not found) than below then download and install. Download the source code from the GNU site and save to c:\projects * http://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.gz * http://ftp.gnu.org/gnu/automake/automake-1.11.1.tar.gz * http://ftp.gnu.org/gnu/libtool/libtool-2.4.tar.gz {{{ cd ${PROJECTS} tar -xvf autoconf-2.65.tar.gz cd autoconf-2.65 ./configure --host=${MINGHOST} --prefix=/mingw (if you are building for 32-bit then use --host=i686-w64-mingw32) make && make install autoconf --version }}} repeat same exercise for automake For libtool {{{ cd ${PROJECTS} tar -xvf libtool-2.4.10.tar.gz cd libtool-2.4.10 ./configure --host=${MINGHOST} --disable-shared --prefix=/mingw #if you get a message that gcc is not usable, then you probably set your # mingw setting wrong or did not install automake/autotools in /mingw #try to fix by rerunning the sh /postinstall/pi.sh again make clean && make && make install libtool --version }}} == 3.b create project folders == {{{ cd ${PROJECTS} mkdir pgx${OS_BUILD} mkdir postgresql mkdir geos mkdir proj mkdir docbook ls }}} == GDAL == {{{ export GDAL_VER=1.9.2 cd ${PROJECTS}/gdal wget http://download.osgeo.org/gdal/gdal-${GDAL_VER}.tar.gz tar xvfz gdal-${GDAL_VER}.tar.gz cd gdal-${GDAL_VER} ./configure --host=${MINGHOST}--build=x86_64-w64-mingw32 --with-threads=no --prefix=${PROJECTS}/gdal/rel-${GDAL_VER}w${OS_BUILD} make && make install cd ${PROJECTS}/gdal/rel-${GDAL_VER}w${OS_BUILD}/bin strip *.dll }}} == DOWNLOAD DOCBOOK == {{{ cd ${PROJECTS}/docbook }}} Download the latest Docbook from http://sourceforge.net/projects/docbook/files/docbook-xsl/ into that folder and untar. Extract somewhere. In this case I chose my projects folder. You'll need to set this folder for the --with-xsldir setting You should have a folder now docbook/docbook-xsl-1.76.1 or something similar == 4. Compiling GEOS == Download latest GEOS source from http://trac.osgeo.org/geos/ You can also use the trunk svn version https://svn.osgeo.org/geos/trunk which is what we use. NOTE: To take advantage of new functions like [http://www.postgis.org/documentation/manual-svn/ST_DelaunayTriangles.html ST_DelaunayTriangles], you need GEOS 3.4dev which is trunk If you are using svn version, make sure to run: {{{ sh autogen.sh }}} --- TO BE CONTINUED --