wiki:DevWikiMingW64_Setup

Building with MingW64 w64, w32 chains

1. Installing Minimalist GNU for Windows-w64 (MinGW-w64)

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.

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 What to download

MingW-w64 site is http://mingw-w64.sourceforge.net 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 )

starting with mingw-w64-bin_x86_64-mingw_20111101_sezero.zip

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. There might be a newer patch use that one.

/ 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 mingw-w64 with MSYS and repeated here for completeness

  • download 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

export OS_BUILD=64
if [[ "${OS_BUILD}" == "64" ]] ; then
	export MINGHOST=x86_64-w64-mingw32
else
	export MINGHOST=i686-w64-mingw32
fi
#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

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

For CUnit

	cd ${PROJECTS}
	wget http://iweb.dl.sourceforge.net/project/cunit/CUnit/2.1-2/CUnit-2.1-2-src.tar.bz2
	tar -xvf CUnit-2.1-2-src.tar.bz2
	cd CUnit-2.1-2
	./configure --build=${MINGHOST} --prefix=/mingw/${MINGHOST}
	make clean
	make && make install
	make check
	exit;
Last modified 11 years ago Last modified on 06/23/13 17:35:04
Note: See TracWiki for help on using the wiki.