Version 88 (modified by 13 years ago) ( diff ) | ,
---|
Compiling using MingGW-w64 for both 32-bit and 64-bit
1. Installing Minimalist GNU for Windows-w64 (MinGW-w64)
The objective will be to try to use the MingGW-w64 toolchain instead of the standard MingW since it has support for both 32-bit and 64-bit compiling. Note: We are not successful yet, but just writing down our steps as we go along.
Details of the prefixes of files can be found at What to download
MingW-w64 site is http://mingw-w64.sourceforge.net
- If you are on 64-bit Windows download one of the binary packages from http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/ with name
starting with mingw-w64-1.0-bin_i686-mingw_
- If you are on 32-bit Windows download one of the binary packages from http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/ with name starting with
mingw-w32-1.0-bin_i686-mingw_ (for my purposes I used mingw-w32-1.0-bin_i686-mingw_20110408.zip) and for native 64-bit (currently using mingw-w64-1.0-bin_i686-mingw_20110516)
- Extract your respective zip into a folder called C:\mingw_w64 or c:\mingw_w32
- Add c:\mingw_w64\bin (or c:\mingw_w32\bin) to your windows environment path variable in System Control Panel Advanced Settings -- PATH
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:\Msys
- launch msys.bat
- type
sh /postinstall/pi.sh
When prompted type in
C:/mingw_w64/mingw
or C:/mingw_w32/mingw
depending on which tool chain you chose
Once done, type logout and the console should exit.
3a. Installing Autoconf, Automake and Libtool
Relaunch C:\mysy\msys.bat
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.xz
cd /c/projects tar -xvf autoconf-2.65.tar.gz cd autoconf-2.65 ./configure --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 (if you are building for 64-bit then use --build=x86_64-w64-mingw32) make && make install autoconf --version
repeat same exercise for automake
For libtool
cd /c/projects tar -xvf libtool-2.4.10.tar.gz cd libtool-2.4 ./configure --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --disable-shared #if you are building for 64-bit then use --host=x86_64-w64-mingw32 for the build,host,target make clean && make && make install libtool --version
3.b create project folders
cd /c/projects mkdir pg mkdir postgresql mkdir geos mkdir proj ls
GDAL
cd /c/projects mkdir gdal cd gdal wget http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz tar xvfz gdal-1.9.0.tar.gz cd gdal-1.9.0 # if you have single toolchain (not a cross compiling chain no need to specify --host, --target, --build) ./configure --prefix=/c/projects/gdal/rel-gdal-1.9.0w64 cd apps make gdal-config cd .. make && make install
4. Compiling GEOS
Download latest GEOS source from http://trac.osgeo.org/geos/ either the http://download.osgeo.org/geos/geos-3.3.0.tar.bz2 or http://download.osgeo.org/geos/geos-svn.tar.bz2 and copy to c:\projects\geos. You can also use the trunk svn version https://svn.osgeo.org/geos/trunk. If you are using svn version, make sure to run:
sh autogen.sh
(THIS WE DON'T THINK IS NECESSARY ANYMORE and we didn't do it)
I had to comment out the lines as seen below, lines 159 and 166 in your mingw*\include\c++\4.4.6\cwchar
//using ::swprintf; //using ::vswprintf;
We don't think this is necessary either If you get errors about g++ and libstdc++ moved try this If you are runnning gcc 4.4.0+ and you get complaints about link g++ you probably need to do this too. Changing file: mingw*\i686-w64-mingw32\lib32\libstdc++.la
library_names='libstdc++.dll.a'
to
#library_names='libstdc++.dll.a' library_names='libstdc++.a'
#this currently fails at linker phase with a whole bunch of
simplify/.libs/libsimplify.a(TopologyPreservingSimplifier.o):TopologyPreservingS implifier.cpp:(.rdata+0x1f0): undefined reference to `geos::geom::util::GeometryTransformer::transformGeometryCollection(geos::geom::GeometryCollection const*, geos::geom::Geometry const*)' and bunch of other classes in util::GeometryTransformer.. the .la file gets created so seems to be at linker phase.
cd /c/projects/geos tar xjf geos-3.3.0.tar.bz2 cd geos-3.3.0 ./configure --prefix=/c/projects/geos/rel-3.3.0 --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 make make install
To strip all the debug info weight from the libgeos DLL files, run
# strip /c/projects/bin/geos/rel-3.3.0/*.dll
Installing LibIconv
For iconv we are going to compile our own copy instead of installing from GNUWin.
Save the source in your C:\projects directory. Open up the MSYS terminal. Ignore the errors in the configure process.
cd /c/projects tar xvfz libiconv-1.13.1.tar.gz cd libiconv-1.13.1 ./configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/c/projects/rel-libiconv-1.13.1w64 make make install
Copy rel-.. contents int c:\mingw\mingw64 folder. For some reason using libiconv-prefix did not work for configuring postgis. Verify if the version of iconv you are running is the same as the one you just compiled (1.13):
# iconv --version
Compiling Proj
Download Proj4 from the web site, and the datum shifts grid file.
- http://download.osgeo.org/proj/proj-4.7.0.tar.gz
- http://download.osgeo.org/proj/proj-datumgrid-1.5.zip
and copy to c:\projects\proj The datum grid file must be unzipped into the "nad" subdirectory of the Proj4 source tree.
cd /c/projects/proj tar xvfz proj-4.7.0.tar.gz cd proj-4.7.0 cd nad unzip ../../proj-datumgrid-1.5.zip cd ..
Apply mutex patch in http://trac.osgeo.org/proj/ticket/72 to src/pj_mutex.c
#if you are building for 64-bit then use x86_64-w64-mingw32 for the build,host,target #32 bit uses i686-w64-mingw32 for build, host, target ./configure --prefix=/c/projects/proj/rel-4.7.0w64 --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --enable-shared --disable-static make make install
Seems to give an error on make install (when trying to copy over the nad folder), but generates files in rel-4.7.0. Have to copy the nad folder manually. The .dll file is strangely called libproj-0.dll. of libproj.dll. Oh well.
Compiling and Installing C-Unit
Download from http://sourceforge.net/projects/cunit/ into c:\projects
cd /c/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 #if you are building for 64-bit then use x86_64-w64-mingw32 for the build,host,target #32 bit uses i686-w64-mingw32 for build, host, target ./configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 make && make install
7. Compiling LibXML2
mkdir /c/projects/libxml cd /c/projects/libxml wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz
tar xvfz libxml2-2.7.8.tar.gz cd libxml2-2.7.8 #if you are building for 64-bit then use x86_64-w64-mingw32 for the build,host,target #32 bit uses i686-w64-mingw32 for build, host, target ./configure --prefix=/c/projects/libxml/rel-libxml2-2.7.8w64 --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --enable-shared CFLAGS=-O2 #Note to self: used to have CCFLAGS=LDFLAGS="-Wl,-static" in here will see how it goes without make make install
You might get an error during the configure process
/bin/rm: cannot lstat `libtoolT': No such file or directory
That error seems safe to ignore.
8. Compiling PostgreSQL 9.1
Download source from: http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.bz2
mkdir /c/projects/pgx64 cd postgresql tar -xvjf postgresql-9.1.3.tar.bz2 cd postgresql-9.1.3 #if you are building for 64-bit then use x86_64-w64-mingw32 for the build,host,target #32 bit uses i686-w64-mingw32 for build, host, target ./configure --prefix=/c/projects/pgx64/pg91 \ --build=x86_64-w64-mingw32 \ --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \ --with-pgport=8441 --enable-cassert --enable-debug \ --enable-integer-datetimes --without-zlib make make install #initialize the database cluster /c/projects/pgx64/pg91/bin/initdb -U postgres -D /c/projects/pgx64/pg91/data -A trust
Compiling JSON-C
This is needed if you want ST_GeomFromGeoJSON to be functional. Download http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz and save to c:\projects\json-c
cd /c/projects/json-c tar xvfz json-c-0.9.tar.gz cd json-c-0.9 ## had to compile with -w (disable warnings otherwise it gave errors ./configure --build=x86_64-w64-mingw32 \ --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \ --prefix=/c/projects/json-c/rel-0.9w64 CFLAGS=-w make clean make make install
Compiling PostGIS 2.0
cd /c/projects mkdir postgis cd postgis wget http://www.postgis.org/download/postgis-2.0.0beta2SVN.tar.gz tar xvf postgis-2.0.0beta2SVN cd postgis-2.0.0beta2SVN CPPFLAGS="-I/c/projects/pgx64/pg91/include" LDFLAGS="-L/c/projects/pgx64/pg91/lib" ./configure \ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \ --with-xml2config=/c/projects/libxml/rel-libxml2-2.7.8w64/bin/xml2-config \ --with-pgconfig=/c/projects/pgx64/pg91/bin/pg_config \ --with-geosconfig=/c/projects/geos/rel-3.3.3vcc64/bin/geos-config \ --with-projdir=/c/projects/proj/rel-4.7.0w64 \ --with-gdalconfig=/c/projects/gdal/rel-1.9.0w64/bin/gdal-config \ --with-jsondir=/c/projects/json-c/rel-0.9w64 \ --with-libiconv-prefix=/c/projects/rel-libiconv-1.13.1w64 make make check make install