| 181 | | |
| 182 | | this fails at linker phase with a whole bunch of errors if you compile without doing |
| 183 | | #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] |
| 184 | | mingw64 is picking up the 32-bit dlls from syswow64 instead of the 64-bit dlss from windows/system32 |
| 185 | | I may have over-copied, but to remedy before evening starting configure |
| 186 | | with windows explorer copy the files from windows/system32 |
| 187 | | |
| 188 | | {{{ |
| 189 | | ws2_32.dll, kernel32.dll, advapi32.dll, mscvrt.dll, user32.dll |
| 190 | | }}} |
| 191 | | |
| 192 | | To your folder: C:\mingw\mingw64\x86_64-w64-mingw32\lib |
| 193 | | and then rename them adding a lib extensions so you have |
| 194 | | {{{ |
| 195 | | libws2_32.dll, libkernel32.dll, libadvapi32.dll, libmscvrt.dll, libuser32.dll |
| 196 | | }}} |
| 197 | | |
| 198 | | # hack described in [http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw64_how_to.html#libgeos] |
| 199 | | |
| 200 | | {{{ |
| 201 | | simplify/.libs/libsimplify.a(TopologyPreservingSimplifier.o):TopologyPreservingS |
| 202 | | implifier.cpp:(.rdata+0x1f0): undefined reference to `geos::geom::util::GeometryTransformer::transformGeometryCollection(geos::geom::GeometryCollection const*, |
| 203 | | geos::geom::Geometry const*)' |
| 204 | | |
| 205 | | and bunch of other classes in util::GeometryTransformer.. |
| 206 | | the .la file gets created so seems to be at linker phase. |
| 207 | | }}} |
| 208 | | |
| 209 | | -- follow instructions in [http://www.gaia-gis.it/spatialite-3.0.0-BETA/mingw64_how_to.html#libgeos] |
| 210 | | {{{ |
| 211 | | export GEOS_VER=3.3.5 |
| 212 | | cd ${PROJECTS}/geos |
| 213 | | tar xjf geos-${GEOS_VER}.tar.bz2 |
| 214 | | cd geos-${GEOS_VER} |
| 215 | | ./configure --host=x86_64-w64-mingw32 --prefix=${PROJECTS}/geos/rel-${GEOS_VER}w64 | tee /c/geos_configure_3.3.log |
| 216 | | make |
| 217 | | make install |
| 218 | | }}} |
| 219 | | To strip all the debug info weight from the libgeos DLL files, run |
| 220 | | {{{ |
| 221 | | strip ${PROJECTS}/bin/geos/rel-${GEOS_VER}w64/*.dll |
| 222 | | }}} |
| 223 | | |
| 224 | | == Installing !LibIconv == |
| 225 | | |
| 226 | | For iconv we are going to compile our own copy instead of installing from GNUWin. |
| 227 | | |
| 228 | | * http://ftp.gnu.org/gnu/libiconv/libiconv-1.13.1.tar.gz |
| 229 | | |
| 230 | | Save the source in your C:\ming64\projects directory. Open up the MSYS terminal. Ignore the errors in the configure process. |
| 231 | | {{{ |
| 232 | | cd ${PROJECTS} |
| 233 | | tar xvfz libiconv-1.13.1.tar.gz |
| 234 | | cd libiconv-1.13.1 |
| 235 | | ./configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=${PROJECTS}/rel-libiconv-1.13.1w64 |
| 236 | | make |
| 237 | | make install |
| 238 | | }}} |
| 239 | | Copy rel-.. contents int c:\mingw\mingw64 folder. For some reason using libiconv-prefix did not work for configuring postgis. |
| 240 | | Verify if the version of iconv you are running is the same as the one you just compiled (1.13): |
| 241 | | {{{ |
| 242 | | # iconv --version |
| 243 | | }}} |
| 244 | | |
| 245 | | == Compiling Proj == |
| 246 | | Download Proj4 from the web site, and the datum shifts grid file. |
| 247 | | |
| 248 | | * http://download.osgeo.org/proj/proj-4.8.0.tar.gz |
| 249 | | * http://download.osgeo.org/proj/proj-datumgrid-1.5.zip |
| 250 | | |
| 251 | | and copy to c:\ming64\projects\proj |
| 252 | | The datum grid file must be unzipped into the "nad" subdirectory of the Proj4 source tree. |
| 253 | | {{{ |
| 254 | | #set this to whereever you plan to keep your source |
| 255 | | #I have one for 32-bit and one for 64-bit |
| 256 | | export PROJECTS=/c/ming64/projects |
| 257 | | cd ${PROJECTS}/proj |
| 258 | | wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz |
| 259 | | wget http://download.osgeo.org/proj/proj-datumgrid-1.5.zip |
| 260 | | tar xvfz proj-4.8.0.tar.gz |
| 261 | | cd proj-4.8.0 |
| 262 | | cd nad |
| 263 | | unzip ../../proj-datumgrid-1.5.zip |
| 264 | | cd .. |
| 265 | | ./configure --prefix=${PROJECTS}/proj/rel-4.8.0w64 --host=x86_64-w64-mingw32 --enable-shared |
| 266 | | make clean |
| 267 | | make && make install |
| 268 | | }}} |
| 269 | | |
| 270 | | == Compiling and Installing C-Unit == |
| 271 | | Download from http://sourceforge.net/projects/cunit/ into c:\projects |
| 272 | | |
| 273 | | {{{ |
| 274 | | cd ${PROJECTS} |
| 275 | | wget http://iweb.dl.sourceforge.net/project/cunit/CUnit/2.1-2/CUnit-2.1-2-src.tar.bz2 |
| 276 | | tar -xvf CUnit-2.1-2-src.tar.bz2 |
| 277 | | cd CUnit-2.1-2 |
| 278 | | #if you are building for 64-bit then use x86_64-w64-mingw32 for the build,host,target |
| 279 | | #32 bit uses i686-w64-mingw32 for build, host, target |
| 280 | | ./configure --host=x86_64-w64-mingw32 --prefix=/mingw |
| 281 | | make && make install |
| 282 | | }}} |
| 283 | | |
| 284 | | For some reason, PostGIS couldn't find my cunit install. So I had to copy the files: |
| 285 | | from C:\ming64\mingw64\include\CUnit to C:\ming64\mingw64\x86_64-w64-mingw32\include\CUnit |
| 286 | | == 7. Compiling LibXML2 == |
| 287 | | |
| 288 | | {{{ |
| 289 | | mkdir ${PROJECTS}/libxml |
| 290 | | cd ${PROJECTS}/libxml |
| 291 | | wget ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz |
| 292 | | }}} |
| 293 | | |
| 294 | | |
| 295 | | {{{ |
| 296 | | tar xvfz libxml2-2.7.8.tar.gz |
| 297 | | cd libxml2-2.7.8 |
| 298 | | #if you are building for 64-bit then use x86_64-w64-mingw32 for the build,host,target |
| 299 | | #32 bit uses i686-w64-mingw32 for build, host, target |
| 300 | | ./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 --with-threads=no CFLAGS=-O2 |
| 301 | | #Note to self: used to have CCFLAGS=LDFLAGS="-Wl,-static" in here will see how it goes without |
| 302 | | #If you have pthreads installed, libxml picks it up and royally screws up thus the need for --with-threads=no |
| 303 | | make |
| 304 | | make install |
| 305 | | }}} |
| 306 | | |
| 307 | | You might get an error during the configure process |
| 308 | | {{{ |
| 309 | | /bin/rm: cannot lstat `libtoolT': No such file or directory |
| 310 | | }}} |
| 311 | | |
| 312 | | That error seems safe to ignore. |
| 313 | | |
| 314 | | == 8. Compiling PostgreSQL 9.1 == |
| 315 | | Download source from: |
| 316 | | [http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.bz2] |
| 317 | | |
| 318 | | {{{ |
| 319 | | mkdir ${PROJECTS}/pgx64 |
| 320 | | cd postgresql |
| 321 | | tar -xvjf postgresql-9.1.3.tar.bz2 |
| 322 | | cd postgresql-9.1.3 |
| 323 | | #if you are building for 64-bit then use x86_64-w64-mingw32 for the build,host,target |
| 324 | | #32 bit uses i686-w64-mingw32 for build, host, target |
| 325 | | #EnterpriseDb VC++ 64-bit builds are compiled with disable float8 by val. |
| 326 | | #If we don't include this line, the modules compiled against mingw64 will be incompatible with edb builds |
| 327 | | ./configure --prefix=${PROJECTS}/pgx64/pg91 \ |
| 328 | | --build=x86_64-w64-mingw32 \ |
| 329 | | --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \ |
| 330 | | --with-pgport=5441 --enable-cassert --enable-debug \ |
| 331 | | --enable-integer-datetimes --disable-float8-byval --without-zlib |
| 332 | | |
| 333 | | make |
| 334 | | make install |
| 335 | | #initialize the database cluster |
| 336 | | /c/projects/pgx64/pg91/bin/initdb -U postgres -D ${PROJECTS}/pgx64/pg91/data -A trust |
| 337 | | }}} |
| 338 | | |
| 339 | | == Compiling JSON-C == |
| 340 | | This is needed if you want ST_GeomFromGeoJSON to be functional. |
| 341 | | Download [http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz] and save to c:\ming64\projects\json-c |
| 342 | | {{{ |
| 343 | | cd ${PROJECTS}/json-c |
| 344 | | wget http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz |
| 345 | | tar xvfz json-c-0.9.tar.gz |
| 346 | | cd json-c-0.9 |
| 347 | | ## had to compile with -w (disable warnings otherwise it gave errors) |
| 348 | | ## if using 32-bit (ming32), use i686-w64-mingw32 for host/build |
| 349 | | ./configure --build=x86_64-w64-mingw32 \ |
| 350 | | --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \ |
| 351 | | --prefix=/c/projects/json-c/rel-0.9w64 CFLAGS=-w |
| 352 | | make clean |
| 353 | | make |
| 354 | | make install |
| 355 | | }}} |
| 356 | | == Copy over needed dlls to PostgreSQL folders == |
| 357 | | |
| 358 | | {{{ |
| 359 | | export PATHOLD=$PATH |
| 360 | | export PATH=$PATH:/c/projects/pgx64/pg91edb/bin:/mingw |
| 361 | | export PGHOST=localhost |
| 362 | | export PGPORT=5441 |
| 363 | | export PGUSER=postgres |
| 364 | | cp /c/projects/geos/rel-3.3.3w64/bin/*.dll /c/projects/pgx64/pg91edb/bin |
| 365 | | cp /c/projects/gdal/rel-1.9.0w64/bin/*.dll /c/projects/pgx64/pg91edb/bin |
| 366 | | cp /c/projects/proj/rel-4.7.0w64/bin/*.dll /c/projects/pgx64/pg91edb/bin |
| 367 | | cp /c/mingw/mingw64/bin/libgcc_s_sjlj-1.dll /c/projects/pgx64/pg91edb/bin |
| 368 | | cp /c/projects/geos/rel-3.3.3w64/bin/*.dll /c/projects/pgx64/pg91/bin |
| 369 | | cp /c/projects/gdal/rel-1.9.0w64/bin/*.dll /c/projects/pgx64/pg91/bin |
| 370 | | cp /c/projects/proj/rel-4.7.0w64/bin/*.dll /c/projects/pgx64/pg91/bin |
| 371 | | cp /c/mingw/mingw64/bin/libgcc_s_sjlj-1.dll /c/projects/pgx64/pg91/bin |
| 372 | | }}} |
| 373 | | |
| 374 | | == Getting GTK == |
| 375 | | If you want to build the shp2pgsql-gui loader in 64-bit, you can use the pre-compiled gtk bundle |
| 376 | | which already has the needed headers |
| 377 | | |
| 378 | | {{{ |
| 379 | | export PORJECTS=/c/ming64/projects/gtk |
| 380 | | cd ${PROJECTS} |
| 381 | | mkdir gtk |
| 382 | | cd gtk |
| 383 | | wget |
| 384 | | http://ftp.gnome.org/pub/gnome/binaries/win64/gtk+/2.22/gtk+-bundle_2.22.1-20101229_win64.zip |
| 385 | | unzip gtk+-bundle_2.22.1-20101229_win64.zip |
| 386 | | }}} |
| 387 | | |
| 388 | | |
| 389 | | |
| 390 | | == Compiling PostGIS 2.0 == |
| 391 | | * There is a problem at least for my Mingw64 that prevents functions like ST_AsText and ST_AsKML that makes it leave out digits randomly |
| 392 | | * This also causes issues for shp2pgsql. The issue is the fact that the MingW64 chain uses |
| 393 | | * Microsoft's vsprintf version instead of the C99 one. This version when space is not enough returns an error code instead of length of output the write |
| 394 | | * To work around this issue, I put in this pretty ugly hack in the liblwgeom/string_buffer.c around line 210 |
| 395 | | change: |
| 396 | | {{{ |
| 397 | | if ( len < 0 ) |
| 398 | | return len; |
| 399 | | }}} |
| 400 | | |
| 401 | | to: |
| 402 | | {{{ |
| 403 | | if ( len < 0 ) |
| 404 | | len = _vscprintf(fmt, ap2); |
| 405 | | }}} |
| 406 | | |
| 407 | | Details of this issue are outlined in #1668 |
| 408 | | |
| 409 | | {{{ |
| 410 | | export PROJECTS=/c/ming64/projects |
| 411 | | export PG_VER=91 |
| 412 | | export PGWINVER=${PG_VER}edb |
| 413 | | export GEOS_VER=3.3.5 |
| 414 | | # had to override the paths since cunit was picking up 32-bit junk and crashing |
| 415 | | export PATHOLD=".:/bin:/include:/mingw/bin:/mingw/include:/c/Windows/system32:/c/Windows:/c/ming64/mingw64/include" |
| 416 | | export PATH="${PATHOLD}:${PROJECTS}/pgx64/pg${PG_VER}/bin:${PROJECTS}/pgx64/pg${PG_VER}/lib" |
| 417 | | #needed to build comments and shp2pgsql-gui |
| 418 | | export PATH="${PATH}:${PROJECTS}/xsltproc:${PROJECTS}/gtk/bin" |
| 419 | | export POSTGIS_SRC=${PROJECTS}/postgis/postgis-${POSTGIS_MICRO_VER} |
| 420 | | cd /c/ming64/projects |
| 421 | | mkdir postgis |
| 422 | | cd postgis |
| 423 | | wget http://www.postgis.org/download/postgis-${POSTGIS_MICRO_VER}.tar.gz |
| 424 | | tar xvf postgis-${POSTGIS_MICRO_VER}.tar.gz |
| 425 | | cd ${POSTGIS_SRC} |
| 426 | | |
| 427 | | CPPFLAGS="-I${PROJECTS}/pgx64/pg${PG_VER}/include -I${PROJECTS}/gettextrel-gettext-0.18.1/include -I${PROJECTS}/rel-libiconv-1.13.1w64/include" \ |
| 428 | | LDFLAGS="-L${PROJECTS}/pgx64/pg${PG_VER}/lib -L${PROJECTS}/gdal/rel-${GDAL_VER}/lib -L${PROJECTS}/gettext/rel-gettext-0.18.1/lib -L${PROJECTS}/rel-libiconv-1.13.1w64/lib" ./configure \ |
| 429 | | --host=x86_64-w64-mingw32 \ |
| 430 | | --with-xml2config=${PROJECTS}/libxml/rel-libxml2-2.7.8w64/bin/xml2-config \ |
| 431 | | --with-pgconfig=${PROJECTS}/pgx64/pg${PG_VER}/bin/pg_config \ |
| 432 | | --with-geosconfig=${PROJECTS}/geos/rel-${GEOS_VER}/bin/geos-config \ |
| 433 | | --with-projdir=${PROJECTS}/proj/rel-4.7.0w64 \ |
| 434 | | --with-gdalconfig=${PROJECTS}/gdal/rel-${GDAL_VER}/bin/gdal-config \ |
| 435 | | --with-jsondir=${PROJECTS}/json-c/rel-0.9w64 \ |
| 436 | | --with-libiconv=${PROJECTS}/rel-libiconv-1.13.1w64 \ |
| 437 | | --with-xsldir=${PROJECTS}/docbook/docbook-xsl-1.76.1 \ |
| 438 | | --with-gui --with-gettext=no |
| 439 | | }}} |
| 440 | | |
| 441 | | #this part is a hack, but again didn't work without it |
| 442 | | #you can try without doing this, but if you get errors about |
| 443 | | # conflicting type def boolean during PostGIS compile, you need this. |
| 444 | | #In my case I got this: |
| 445 | | {{{ |
| 446 | | In file included from c:/ming64/projects/json-c/rel-0.9w64/include/json/json_util.h:1 |
| 447 | | |
| 448 | | from c:/projects/json-c/rel-0.9w64/include/json/json.h:23, |
| 449 | | from lwgeom_in_geojson.c:31: |
| 450 | | c:/ming64/projects/json-c/rel-0.9w64/include/json/json_object.h:32: error: conflictin |
| 451 | | types for 'boolean' |
| 452 | | c:\mingw\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.4.7/../../../../x86_64-w6 |
| 453 | | mingw32/include/rpcndr.h:52: note: previous declaration of 'boolean' was here |
| 454 | | make[1]: *** [lwgeom_in_geojson.o] Error 1 |
| 455 | | }}} |
| 456 | | |
| 457 | | * Open up /c/projects/json-c/rel-0.9/include/json/json_object.h |
| 458 | | * remark out line 32 that reads |
| 459 | | {{{ typedef int boolean }}} |
| 460 | | * so it should now read |
| 461 | | {{{ /** typedef int boolean; **/ }}} |
| 462 | | * During the PostGIS configure process, you have to put this back the way it was otherwise configure complains json.h or something is not usable and refuses to configure with JSON-C support. Then you remark the line out again during compile. Crazy I know, but json-c won't compile without that line so can't take it out before json-c compile. |
| 463 | | |
| 464 | | If you run into problems with your build, pipe the output into a file for further analysis. The GUI requires that pkg-config be on your PATH, check that it is there by running 'which pkg-config'. |
| 465 | | {{{ |
| 466 | | make 2>&1 | tee /c/build.log |
| 467 | | make check |
| 468 | | make install |
| 469 | | }}} |
| | 195 | --- TO BE CONTINUED -- |