Changes between Initial Version and Version 1 of DevWikiWinMingWSys_20_MSVC


Ignore:
Timestamp:
Feb 27, 2012, 10:08:09 PM (12 years ago)
Author:
pramsey
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • DevWikiWinMingWSys_20_MSVC

    v1 v1  
     1= PostGIS 2.0 Build Using MinGW/MSYS/VisualC++ =
     2
     3These directions are based on building a PostGIS 2.0 installation using a mixture of MinGW and Visual C++ (MSVC). Some of the libraries that PostGIS 2.0 depends on, such as GEOS and GDAL, are more frequently built and tested under MSVC than under MinGW.
     4
     5== Operating System ==
     6
     7This build recipe has been put together and tested on Windows XP, with all current patches from Microsoft.
     8
     9== MinGW/MSYS ==
     10
     11MinGW/MSYS have been recently revived using a lightweight package manager called '"mingw-get". Like apt-get and yum, mingw-get makes it very easy to pull down pieces of software and all the necessary dependencies in one step. First get the base installer for mingw-get.
     12
     13http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/mingw-get-inst-20111118/mingw-get-inst-20111118.exe
     14
     15Run the installer, and opt for support of C, C++ and MSYS. Once the install is finished, open up the "MinGW Shell" and run the following commands:
     16
     17{{{
     18mingw-get install msys-bison msys-flex
     19mingw-get install msys-unzip msys-zip
     20mingw-get install msys-autoconf
     21mingw-get install msys-automake
     22mingw-get install msys-libtool
     23mingw-get install msys-wget
     24mingw-get install mingw32-gettext
     25mingw-get install mingw32-libiconv
     26mingw-get install mingw32-zlib mingw32-libz
     27mingw-get install mingw-utils
     28}}}
     29
     30Then set up the build and target directories:
     31
     32{{{
     33# target directory
     34mkdir /c/pgsql
     35
     36# build directory
     37mkdir /c/build/
     38mkdir /c/build/sources
     39mkdir /c/build/binaries
     40}}}
     41
     42== SVN ==
     43
     44In order to build the latest versions of PostGIS 2.0 you will need an SVN client, so download a command line SVN client:
     45
     46{{{
     47cd /c/build/binaries
     48wget http://www.sliksvn.com/pub/Slik-Subversion-1.7.2-win32.msi
     49}}}
     50
     51Once you've downloaded, install with the default options.
     52
     53== Visual C++ Express ==
     54
     55To build the MSVC libraries, you will need the free version of Visual C++, which microsoft makes available.
     56
     57http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express
     58
     59Download Visual C++ Express and install it.
     60
     61== CMake ==
     62
     63CMake is a multi-platform build tool, used by GEOS to control compilation on non-UNIX platforms.  Download CMake from:
     64
     65http://www.cmake.org/cmake/resources/software.html
     66
     67Install, and opt to add to system path for all users when prompted.
     68
     69== GEOS ==
     70
     71GEOS is the geometry library underlying most of the PostGIS geometry functions.
     72
     73{{{
     74cd /c/build/sources
     75wget http://download.osgeo.org/geos/geos-3.3.3.tar.bz2
     76tar xvfj geos-3.3.3.tar.bz2
     77mkdir geos-3.3.3-build
     78cd geos-3.3.3
     79./configure --prefix=/c/pgsql
     80}}}
     81
     82Edit the CMakeLists.txt file and the following line to stop floating point precision issues (which will lead to regression failures in PostGIS later on if you don't make the change)
     83{{{
     84set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /fp:strict /fp:except-")
     85}}}
     86right before this line
     87{{{
     88add_definitions(-D_SCL_SECURE_NO_WARNINGS)
     89}}}
     90
     91Open up the "Visual Studio 2008 Command Prompt", and run the build commands below.
     92
     93{{{
     94cd \
     95cd build
     96cd sources
     97cd geos-3.2.2-build
     98cmake -G "NMake MakeFiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=C:\pgsql ..\geos-3.3.2
     99nmake
     100nmake install
     101}}}
     102
     103Open up the "MinGW Shell" and clean out the static libraries and copy the dynamic libraries over to the lib dir:
     104
     105{{{
     106cd /c/pgsql/bin
     107cp geos*dll ../lib
     108cd ../lib
     109rm geos*.lib
     110}}}
     111
     112Now you have GEOS, but PostGIS is going to need a geos-config file to build, so...
     113
     114{{{
     115cd /c/build/sources/geos-3.3.3
     116cp tools/geos-config /c/pgsql/bin
     117chmod 755 /c/pgsql/bin/geos-config
     118}}}
     119
     120== PostgreSQL ==
     121
     122{{{
     123cd /c/build/sources
     124wget http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.bz2
     125tar xvfj postgresql-9.1.2.tar.bz2
     126cd postgresql-9.1.2
     127./configure --prefix=/c/pgsql
     128make
     129make install
     130}}}
     131
     132== CUnit ==
     133
     134{{{
     135cd /c/build/sources
     136wget http://downloads.sourceforge.net/project/cunit/CUnit/2.1-2/CUnit-2.1-2-src.tar.bz2
     137tar xvfj CUnit-2.1-2-src.tar.bz2
     138cd CUnit-2.1-2
     139./configure --prefix=/c/pgsql
     140make
     141make install
     142}}}
     143
     144== Proj ==
     145
     146{{{
     147cd /c/build/sources
     148wget http://download.osgeo.org/proj/proj-4.6.1.tar.gz
     149wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
     150tar xvfz proj-4.6.1.tar.gz
     151cd proj-4.6.1/nad
     152unzip ../../proj-datumgrid-1.5.zip
     153}}}
     154
     155Edit the nmake.opt file and set the INSTDIR variable to "c:\pgsql".
     156
     157Open up the "Visual Studio 2008 Command Prompt"
     158
     159{{{
     160cd \
     161cd build\sources\proj-4.6.1
     162nmake -f makefile.vc
     163nmake -f makefile.vc install-all
     164}}}
     165
     166Open up the "MinGW Shell" and clean out the static libraries and copy the dynamic libraries over to the lib dir:
     167
     168{{{
     169cd /c/pgsql/bin
     170cp proj*dll ../lib
     171cd ../lib
     172rm proj*.lib
     173}}}
     174
     175== GTK+ Bundle ==
     176
     177{{{
     178cd /c/build/binaries
     179wget http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip
     180unzip gtk+-bundle_2.24.10-20120208_win32.zip -d /c/pgsql
     181}}}
     182
     183== EnterpriseDB PostgreSQL ==
     184
     185If you're planning on eventually copying the binaries into an EnterpriseDB build for distribution here's where to get the binaries:
     186
     187{{{
     188cd /c/build/binaries
     189wget http://get.enterprisedb.com/postgresql/postgresql-9.1.2-1-windows-binaries.zip
     190mkdir /c/pgsql-edb
     191unzip postgresql-9.1.2-1-windows-binaries.zip -d /c/pgsql-edb
     192}}}
     193
     194== LibXML2 ==
     195
     196You have to get libxml2 and its dependencies, iconv and zlib.
     197
     198{{{
     199cd /c/build/binaries
     200wget ftp://ftp.zlatkovic.com/libxml/libxml2-2.7.8.win32.zip
     201wget ftp://ftp.zlatkovic.com/libxml/iconv-1.9.2.win32.zip
     202wget ftp://ftp.zlatkovic.com/libxml/zlib-1.2.5.win32.zip
     203
     204unzip libxml2-2.7.8.win32.zip
     205cd libxml2-2.7.8.win32
     206cp -r bin/* /c/pgsql/bin
     207cp -r bin/* /c/pgsql/lib
     208cp -r include /c/pgsql/
     209cd ..
     210
     211unzip iconv-1.9.2.win32.zip
     212cd iconv-1.9.2.win32
     213cp -r bin/* /c/pgsql/bin
     214cp -r bin/* /c/pgsql/lib
     215cp -r include /c/pgsql/
     216cd ..
     217
     218unzip zlib-1.2.5.win32.zip
     219cd zlib-1.2.5.win32
     220cp -r bin/* /c/pgsql/bin
     221cp -r bin/* /c/pgsql/lib
     222cp -r include /c/pgsql/
     223cd ..
     224}}}
     225
     226Now you have libxml2, but you don't have an xml2-config file. So...
     227
     228{{{
     229cp /c/pgsql/bin/geos-config /c/pgsql/bin/xml2-config
     230}}}
     231
     232Now edit /c/pgsql/bin/xml2-config so it returns the right answers!
     233
     234 * Change the --libes option so that "-lgeos" becomes "-lxml2 -lz -lpthread -liconv -lm"
     235 * Change the --cflags option to return "-I/c/pgsql/include/libxml"
     236
     237== JSON-C ==
     238
     239{{{
     240cd /c/build/sources
     241wget http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz
     242tar xvfz json-c-0.9.tar.gz
     243cd json-c-0.9
     244CFLAGS=-w ./configure --prefix=/c/pgsql --enable-shared --disable-static
     245make
     246make install
     247cd /c/pgsql/lib
     248a2dll libjson.a -o libjson.dll
     249cp libjson.dll ../bin
     250rm libjson.a
     251}}}
     252
     253== GDAL ==
     254
     255Getting a working GDAL is an involved process...
     256
     257{{{
     258cd /c/build/sources
     259http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
     260tar xvfz gdal-1.9.0.tar.gz
     261cd gdal-1.9.0
     262./configure --prefix=/c/pgsql
     263cd apps
     264make gdal-config
     265}}}
     266
     267In order get get all the symbols linking you need to edit nmake.opt appropriately. Find the following line in the file and disable STDCALL by following the directions (commenting out the line and adding the CPL_DISABLE_STDCALL flag to the OPTFLAGS later in the file.
     268{{{
     269# If you don't want some entry points to have STDCALL conventions,
     270# comment out the following and add -DCPL_DISABLE_STDCALL in OPTFLAGS.
     271# This option has no effect on 64-bit windows.
     272#STDCALL=YES
     273}}}
     274While you're at it, also carry out the following edits:
     275{{{
     276GDAL_HOME = "C:\pgsql"
     277}}}
     278Set the version string to blank
     279{{{
     280VERSION =
     281}}}
     282Note on the above: Blanking out the version string is necessarily to line up the DLL name with the expectation of the PostGIS configure script that gdal will be named "gdal" and not "gdal19". This is fine for a one-time compile, but in the long run, to avoid DLL conflicts, we would be better off with a properly named GDAL and having the PostGIS configure process pick up the right name from the gdal-config script and apply it to all tests.
     283
     284Open up the "Visual Studio 2008 Command Prompt"
     285
     286{{{
     287nmake -f makefile.vc MSVC_VER=1500
     288nmake -f makefile.vc MSVC_VER=1500 install
     289}}}
     290
     291Copy the dynamic gdal-config script into place.
     292{{{
     293cp apps/gdal-config /c/pgsql/bin
     294chmod 755 /c/pgsql/bin/gdal-config
     295}}}
     296Copy the static libraries across
     297{{{
     298cp /c/pgsql/bin/gdal19.dll /c/pgdal/lib/gdal.dll
     299}}}
     300
     301Ensure gdal-config returns the right answers!
     302
     303Copy the header files over, since the install process seems to not move them.
     304{{{
     305cd /c/build/sources/gdal-1.9.0
     306cp gcore/*.h /c/pgsql/include
     307cp port/*.h /c/pgsql/include
     308cp ogr/*.h /c/pgsql/include
     309cp alg/*.h /c/pgsql/include
     310cp frmts/vrt/*.h /c/pgsql/include
     311}}}
     312
     313== PostGIS ==
     314
     315Now we are ready to try and build PostGIS. Using the "MinGW Shell",
     316
     317{{{
     318cd /c/build/sources
     319svn co http://svn.osgeo.org/postgis/trunk postgis-svn
     320export PATH=$PATH:/c/pgsql/bin
     321}}}
     322
     323Before building, edit one file to allow the regression tests to run, edit ./regress/Makefile.in and set
     324{{{
     325REGRESS_INSTALLDIR=C:/build/sources/postgis-svn/regress/00-regress-install
     326}}}
     327
     328Now you can configure and build,
     329{{{
     330CPPFLAGS="-I/c/pgsql/include" LDFLAGS="-L/c/pgsql/lib" ./configure \
     331  --with-xml2config=/c/pgsql/bin/xml2-config \
     332  --with-pgconfig=/c/pgsql/bin/pg_config \
     333  --with-geosconfig=/c/pgsql/bin/geos-config \
     334  --with-projdir=/c/pgsql \
     335  --with-gdalconfig=/c/pgsql/bin/gdal-config \
     336  --with-jsondir=/c/pgsql \
     337  --with-libintl-prefix=/c/pgsql \
     338  --with-gui
     339
     340make
     341make check
     342make install
     343}}}