back

Index of contents


the MinGW + MSYS environment

MinGW is an open source C/C++ compiler based on the popular gcc; MSYS is a command shell supporting a minimalistic Linux-like environment on Windows.
Using both them you can build standard open source software [originally developed for Linux] under Windows as well, simply using the classic build tool-chain, as in:

./configure
make
make install

Quite obviously, Windows isn't exactly the same as Linux, so you cannot expect to get always an easy and painless build.
May well be you have to adapt something here and there in order to get a successful build under Windows.
The following notes are aimed exactly to this goal: allow you to avoid wasting your time while fighting against oddities that can quite easily solved.

We'll suppose you are using the current MinGW 5.1.4 and MSYS 1.0.10
So, if you have installed anything using the default settings [the wisest thing to do], now you have the following path correspondence:

C:\msys\1.0\local will be mapped [in the MSYS own perspective] as: /usr/local

Accordingly, this one will be the standard home for any software you'll then build and install.

Step 1) installing libiconv

libiconv is the standard GNU library supporting locale charsets.
Required by: libspatialite, spatialite-tools

Building under Windows is really difficult, so the easiest way is the one to install the precompiled binaries.

Step 2) building libz

libz is a popular library implementing Deflate, i.e. the compression algorithm used by gzip and Zip.
Required by: libpng, libtiff, librasterlite

Building under Windows is quite easy, but requires to pay some attenction. cd zlib123
cp win32/makefile.gcc makefile.gcc
make -fmakefile.gcc
export "INCLUDE_PATH=/usr/local/include"
export "LIBRARY_PATH=/usr/local/lib"
make install -fmakefile.gcc
cp zlib1.dll /usr/local/bin

This will build and install both the static library and the DLL as well.

Step 3) building libjpeg

libjpeg is a popular library supporting the JPEG image compression.
Required by: libtiff, librasterlite

Building under Windows is absolutely a plain and easy task. cd jpeg-8a
./configure
make
make install-strip

This will build and install both the static library and the DLL as well.

Step 4) building libpng

libpng is a popular library supporting the PNG image compression.
Depends on: libz
Required by: librasterlite

Building under Windows is absolutely a plain and easy task. cd lpng141
cp scripts/makefile.mingw .

now you have to manually edit the makefile.mingw file completing some variable defs as follows: make -fmakefile.mingw
cp png.h pngconf.h /usr/local/include
cp libpng.a libpng.dll.a /usr/local/lib
cp libpng14.dll pngtest-stat.exe pngtest.exe /usr/local/bin

Important notice: the latest libpng-1.4.1 doesn't supports ./configure
So you have to apply the above instructions in order to build this library.

Step 5) building libtiff

libtiff is a popular library supporting the TIFF image format.
Depends on: libz, libjpeg
Required by: librasterlite

Building under Windows is absolutely a plain and easy task. cd tiff-3.9.2
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure
make
make install-strip

Important notice: you have to properly set the shell environment in order to retrieve the already installed libz; this is the duty of the two above export directives.

This will build and install both the static library and the DLL as well.

Step 6) building libproj

libproj is a library supporting coordinate's transformation between different Reference Systems [PROJ.4]
Required by: libgeotiff, libspatialite, spatialite-tools

Building under Windows is an easy task. cd proj-4.7.0
./configure --without-mutex
make
make install-strip

Important notice: may well be you'll get the following fatal errors:

pj_mutex.c:167: error: redefinition of 'pj_acquire_lock'
pj_mutex.c:65: error: previous definition of 'pj_acquire_lock' was here
pj_mutex.c:181: error: redefinition of 'pj_release_lock'
pj_mutex.c:75: error: previous definition of 'pj_release_lock' was here
pj_mutex.c:192: error: redefinition of 'pj_cleanup_lock'
pj_mutex.c:82: error: previous definition of 'pj_cleanup_lock' was here
pj_mutex.c:206: error: redefinition of 'pj_init_lock'
pj_mutex.c:91: error: previous definition of 'pj_init_lock' was here

in such an evenience you have to edit the -/src/pj_mutex.c source as follows:

33c33
< #ifndef _WIN32
---
> #if defined (_WIN32) && !defined(__MINGW32__)

40c40
< #ifndef _WIN32
---
> #if defined (_WIN32) && !defined(__MINGW32__)

Step 7) building libgeotiff

libgeotiff is a library supporting the GeoTIFF raster format
Depends on: libz, libjpeg, libtiff, libproj
Required by: librasterlite

Building under Windows is an easy task. cd libgeotiff-1.2.5
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --enable-incode-epsg
make
make install

Important notice: it doesn't seem possible to build as a DLL using MinGW + MSYS. AFAIK, there is no way to do such a thing.


Step 8) building libgeos

libgeos is a library representing a C++ porting of JTS [Java Topology Suite].
Required by: libspatialite, spatialite-tools

This library really is an huge and complex piece of software; building on Windows is an incredibly time consuming task, and may be quite complex. cd geos-3.2.0
./configure
make
make install-strip

This will build and install both the static library and the DLL as well.

Important notice: using standard MinGW you'll get the following fatal errors:

C:/MinGW/bin/../gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/cwchar:161:
error: '::swprintf' has not been declared

C:/MinGW/bin/../gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/cwchar:168:
error: '::vswprintf' has not been declared


This is because GEOS sets the -ansi switch, and MinGW support for strict ANSI mode is somehow broken.
Fixing this issue requires some little hacking:
line 160    using ::putwchar;
line 161    // using ::swprintf;
line 162    using ::swscanf;
line 163    using ::ungetwc;
line 164    using ::vfwprintf;
line 165#if _GLIBCXX_HAVE_VFWSCANF
line 166    using ::vfwscanf;
line 167#endif
line 168    // using ::vswprintf;
line 169#if _GLIBCXX_HAVE_VSWSCANF
line 170    using ::vswscanf;
line 171#endif
line 172    using ::vwprintf;

Step 9) building libspatialite

libspatialite is the main core of SpatiaLite
Depends on: libiconv, libproj, libgeos
Required by: spatialite-tools, librasterlite

Building under Windows is an easy task. cd libspatialite-amalgamation-2.4.0
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --target=mingw32
make
make install-strip

This will build and install both the static library and the DLL as well.

Step 10) building spatialite-tools

spatialite-tools the SpatiaLite command-line management tools
Depends on: libiconv, libproj, libgeos, libspatialite
Building under Windows is an easy task. cd spatialite-tools-2.4.0
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure --target=mingw32
make
make install-strip


Step 11) building librasterlite

librasterlite is the main core of RasterLite, this including any related command-line management tool
Depends on: libjpeg, libpng, libtiff, libgeotiff, libproj, libspatialite

Building under Windows is an easy task. cd librasterlite-1.0
export "CFLAGS=-I/usr/local/include"
export "LDFLAGS=-L/usr/local/lib"
./configure
make
make install-strip

This will build and install both the static library and the DLL, and any dynamically linked [i.e. based on DLLs] management tool as well.
If you wish instead to build statically linked management tools [i.e. self contained, not depending on DLLs], now type:

mkdir static_bin
make -f Makefile-static-MinGW
cp static_bin/* /usr/local/lib


Step 12) building wxWidgets MSW

wxWidgets is a popular widgets library, supporting GUI in a cross-platform fashion; MSW is the specific porting supporting Windows.
Required by: spatialite-gui, spatialite-gis

This library really is an huge and complex piece of software; building on Windows is an incredibly time consuming task, but is quite plain and easy. cd wxMSW-2.8.10
mkdir msw_build
cd msw_build
../configure --disable-shared --disable-debug --disable-threads --enable-monolithic --enable-unicode --enable-graphics_ctx

Please note: the wxMSW ./configure is highly configurable: you must apply exactly the above settings.
Anyway, when ./configure stops, it's a good practice to check if the final report looks exactly like this:

Configured wxWidgets 2.8.10 for `i686-pc-mingw32'

  Which GUI toolkit should wxWidgets use?                 msw
  Should wxWidgets be compiled into single library?       yes
  Should wxWidgets be compiled in debug mode?             no
  Should wxWidgets be linked as a shared library?         no
  Should wxWidgets be compiled in Unicode mode?           yes
  What level of wxWidgets compatibility should be enabled?
                                       wxWidgets 2.4      no
                                       wxWidgets 2.6      yes
  Which libraries should wxWidgets use?
                                       jpeg               builtin
                                       png                builtin
                                       regex              builtin
                                       tiff               builtin
                                       zlib               builtin
                                       odbc               no
                                       expat              builtin
                                       libmspack          no
                                       sdl                no

now, when ./configure stops, you have to continue as usual:

make
make install-strip

Important notice: using standard MinGW you'll get lots of fatal errors, deriving from missing Platform SDK headers, as in:

../src/msw/graphics.cpp:92:21: gdiplus.h: No such file or directory

This is because GDI+ [advanced graphics for Windows] isn't supported by standard MinGW.
You can patch your MinGW as explained here: MinGW-users
After applying this patch, wxMSW will build without any further problem.

back