Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ogr_fdw building dependencies and fdw under mingw64. For this I used mingw64 x86_64-4.8.3-win32-seh-rt_v3-rev1 (
#my windows 64-bit build chain described here is available at
#(with most of these libraries already built)
#My 32-bit chain is much the same except uses gcc 4.8.1, I'll be posting that as well after I clean it up a bit
#Paul's instructions for setting up mingw on 32-bit are pretty close in concept -
#Although these are built with mingw64 chain, they are designed to work with the EDB VC++ distributions of PostgreSQL
export OS_BUILD=64
export GCC_TYPE=gcc48
if [[ "${OS_BUILD}" == "64" ]] ; then
export MINGHOST=x86_64-w64-mingw32
export MINGHOST=i686-w64-mingw32
#compile postgresql 9.5+ (can do the same for other versions of postgresql you want to build for)
# prior versions needed configure --disable-float8-byval (from 9.5 on the VC++ builds no longer use that
# so for older put in --disable-float8-byval to be compatible with EDB VC++, and 9.5+ take it out.)
if true; then
mkdir ${PROJECTS}/postgresql
cd ${PROJECTS}/postgresql
export PG_VER=9.6w${OS_BUILD}${GCC_TYPE}
export PG_VER_FULL=9.6.2
export PG_DIR=${PROJECTS}/postgresql/postgresql-${PG_VER_FULL}
rm -rf postgresql-${PG_VER_FULL}
tar -xvjf postgresql-${PG_VER_FULL}.tar.bz2
cd postgresql-${PG_VER_FULL}
export PATH="${PROJECTS}/rel/pg${PG_VER}/bin:${PROJECTS}/rel/pg${PG_VER}/lib:$PATH"
make distclean
#if you are building for 32-bit in 9.4 you need to edit the
#src/template/win32 and change the LDFLAGS
#LDFLAGS="-Wl,--allow-multiple-definition -Wl,--disable-auto-import"
# to LDFLAGS="-Wl,--allow-multiple-definition"
#if you don't then the extensions you build will not work in the VC++ 32-bit PostgreSQL build
#this is a non-issue for 64-bit build
./configure --prefix=${PROJECTS}/postgresql/rel/pg${PG_VER}\
--build=${MINGHOST} \
--with-pgport=8443 --enable-cassert --enable-debug \
make clean
rm -rf ${PROJECTS}/postgresql/rel/pg${PG_VER}
make install
make check
#gmake install-world
cd ${PG_DIR}/contrib/postgres_fdw
make install
cd ${PG_DIR}/contrib/hstore
make install
cd ${PG_DIR}/contrib/fuzzystrmatch
make install
cd ${PG_DIR}/contrib/pg_trgm
make install
#You'll need GDAL refer to my
# for building the GDAL shared library and it's dependencies
##finally we can build ogr_fdw
if true; then
export PGUSER=postgres
export PG_VER=9.6
export GDAL_VER=2.1.3
#for simplicity, I copy all the dependency dlls (sql lite, ssl, curl in rel-gdal*/bin folder
export PGWINVER=${PG_VER}w${OS_BUILD}edb
export PGPATH=${PROJECTS}/postgresql/rel/pg${PG_VER}w${OS_BUILD}${GCC_TYPE}
export PATH="/mingw/bin:/mingw/include:/bin:${PGPATH}/bin:${GDAL_REL_PATH}/bin"
export PGPORT=5446
rm -rf pgsql_ogr_fdw
git clone -b master pgsql_ogr_fdw
cd pgsql_ogr_fdw
git pull
make clean
#since I don't build GDAL with postgresql support the postgresql test fails
#so I sed it out
sed -i 's/pgsql//' Makefile
make install
make installcheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment