| 1 | = Building with MingW64 w64, w32 chains = |
| 2 | == 1. Installing Minimalist GNU for Windows-w64 (MinGW-w64) == |
| 3 | 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. |
| 4 | |
| 5 | We will use MingGW-w64 toolchain instead of the standard MingW since it has support for both 32-bit and 64-bit compiling. |
| 6 | 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''. |
| 7 | |
| 8 | Details of the prefixes of files can be found at [http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure What to download] |
| 9 | |
| 10 | MingW-w64 site is [http://mingw-w64.sourceforge.net] |
| 11 | There are issues with GEOS compile above 4.5.4 or so, in 4.6.1+, the make check crashes and so does |
| 12 | 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 |
| 13 | 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 ) |
| 14 | |
| 15 | * If you are building for 64-bit Windows download the personal build from [http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/sezero_4.5_20111101/] with name |
| 16 | starting with '''mingw-w64-bin_x86_64-mingw_20111101_sezero.zip''' |
| 17 | |
| 18 | * 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 |
| 19 | '''mingw-w32-bin_i686-mingw_20111101_sezero.zip''' |
| 20 | |
| 21 | * Extract your respective zip into a folder called C:\ming64\mingw64 or c:\ming32\mingw32 |
| 22 | * 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. There might be a newer patch use that one. |
| 23 | |
| 24 | |
| 25 | |
| 26 | /** NOTE to self: This may not be necessary anymore **/ |
| 27 | 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 |
| 28 | described in |
| 29 | #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] |
| 30 | mingw64 is picking up the 32-bit dlls from syswow64 instead of the 64-bit dlls from windows/system32 |
| 31 | I only needed to copy ws2_32.dll for geos to compile without errors |
| 32 | Others may be needed not sure. |
| 33 | with windows explorer copy the files from windows/system32 |
| 34 | |
| 35 | {{{ |
| 36 | ws2_32.dll |
| 37 | }}} |
| 38 | |
| 39 | To your folder: C:\ming64\x86_64-w64-mingw32\lib |
| 40 | and then rename them adding a lib extensions so you have |
| 41 | {{{ |
| 42 | libws2_32.dll |
| 43 | # these ones didn't seem necessary for PostGIS: libmsimg32.dll,libgdi32.dll, libcrypt32.dll and libwldap32.dll |
| 44 | }}} |
| 45 | |
| 46 | |
| 47 | == prefixed files == |
| 48 | These sometimes exist only with the prefixes and cause issues during compilation so you'll need prefixless versions |
| 49 | |
| 50 | {{{ |
| 51 | cp /mingw/bin/x86_64-w64-mingw32-cpp.exe /mingw/bin/cpp.exe |
| 52 | cp /mingw/bin/x86_64-w64-mingw32-strip.exe /mingw/bin/strip.exe |
| 53 | }}} |
| 54 | |
| 55 | == 2. Installing Msys == |
| 56 | |
| 57 | 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 |
| 58 | here for completeness |
| 59 | |
| 60 | * 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) |
| 61 | * Extract into a folder called C:\Ming64\msys (or C:\Ming32\msys) |
| 62 | * launch msys.bat |
| 63 | * type |
| 64 | |
| 65 | {{{ |
| 66 | sh /postinstall/pi.sh |
| 67 | }}} |
| 68 | |
| 69 | When prompted type in |
| 70 | {{{C:/ming64/mingw64}}} or {{{C:/ming32/mingw32}}} depending on which tool chain you chose |
| 71 | Once done, type logout and the console should exit. |
| 72 | Note: You can have both if you are using windows 64-bit and we do. |
| 73 | |
| 74 | 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. |
| 75 | |
| 76 | == 3a. Installing Autoconf, Automake and Libtool == |
| 77 | Relaunch C:\ming64\msys\msys.bat (or c:\ming32\msys\msys.bat) |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | We create a file with commands like this |
| 83 | and make sure this is included in all my compile scripts |
| 84 | |
| 85 | {{{ |
| 86 | #if you are building for 32-bit change ming64 to ming32 |
| 87 | export PROJECTS=/c/ming64/projects |
| 88 | #for a 64-bit build |
| 89 | export MINGHOST=x86_64-w64-mingw32 |
| 90 | #if you are building for 32-bit change to this |
| 91 | #export MINGHOST=i686-w64-mingw32 |
| 92 | |
| 93 | #this part is not necessary |
| 94 | #but we like to prefix our binary folders with |
| 95 | #version |
| 96 | export OS_BUILD=64 #change to 32 if building for 32 |
| 97 | }}} |
| 98 | |
| 99 | {{{ |
| 100 | #if you are building for 32-bit change ming64 to ming32 |
| 101 | mkdir ${PROJECTS} |
| 102 | }}} |
| 103 | |
| 104 | |
| 105 | Verify which versions of these you have with |
| 106 | |
| 107 | autoconf --version |
| 108 | |
| 109 | etc. |
| 110 | |
| 111 | If they are not newer (or you get not found) than below then download and install. |
| 112 | Download the source code from the GNU site and save to c:\projects |
| 113 | |
| 114 | * http://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.gz |
| 115 | * http://ftp.gnu.org/gnu/automake/automake-1.11.1.tar.gz |
| 116 | * http://ftp.gnu.org/gnu/libtool/libtool-2.4.tar.gz |
| 117 | |
| 118 | |
| 119 | {{{ |
| 120 | |
| 121 | cd ${PROJECTS} |
| 122 | tar -xvf autoconf-2.65.tar.gz |
| 123 | cd autoconf-2.65 |
| 124 | ./configure --host=${MINGHOST} --prefix=/mingw (if you are building for 32-bit then use --host=i686-w64-mingw32) |
| 125 | make && make install |
| 126 | autoconf --version |
| 127 | }}} |
| 128 | |
| 129 | repeat same exercise for automake |
| 130 | |
| 131 | For libtool |
| 132 | {{{ |
| 133 | cd ${PROJECTS} |
| 134 | tar -xvf libtool-2.4.10.tar.gz |
| 135 | |
| 136 | cd libtool-2.4.10 |
| 137 | ./configure --host=${MINGHOST} --disable-shared --prefix=/mingw |
| 138 | #if you get a message that gcc is not usable, then you probably set your |
| 139 | # mingw setting wrong or did not install automake/autotools in /mingw |
| 140 | #try to fix by rerunning the sh /postinstall/pi.sh again |
| 141 | make clean && make && make install |
| 142 | libtool --version |
| 143 | |
| 144 | }}} |
| 145 | |