| Name | Modified | Size | Downloads / Week | 
|---|---|---|---|
| Parent folder | |||
| README.md | 2013-12-29 | 14.9 kB | |
| HOWTO-64-compile-and-test.txt | 2013-12-03 | 13.2 kB | |
| Totals: 2 Items | 28.0 kB | 0 | |
NEW !
Support for two additional extensions (mysql_fdw and ldap_fdw) have been added to the project. (See This Wiki Page for HOWTO compile them)
Procedure for compiling PosgreSQL-9.3.1 + "sqlite_fdw" + "www_fdw":
(Using mingw-w64 / gcc 4.8.0)
Note 1:
In the following "/usr/local/" corresponds to "C:\mingw64\msys\local\", because I installed MSYS in the root directory of mingw "C:\mingw64" ...
Note 2:
See at the bottom of this page the final value for the "PATH" environment variable (to avoid missing something during the next steps of this procedure).
Setting up the system:
Get MinGW-w64 from: http://netcologne.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.8-release/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z
Note: more up to date gcc (4.8.2) can be downloaded from here: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.8.2/
Add "C:\mingw64\bin" to the "PATH" environment variable
Unpack directory "msys" in "C:\mingw64"
Run C:\ming64\msys\msys.bat { WARNING: Never run msys in RUNAS (Administrator) mode !!! }
Setup tools:
- Install a standard MinGW using "mingw-get-setup.exe" http://netcologne.dl.sourceforge.net/project/mingw/Installer/mingw-get-setup.exe
- Make sure to select the Msys and the developer toolkit (in addition to the C compiler)
- cd /c/MinGW/
- Copy all nux tools from "/bin"*
- rsync --exclude=.exe --exclude=.dll bin/* /c/mingw64/bin/
- Copy all from "/share"
- rsync -a --exclude=gcc --exclude=gdb --exclude=info --exclude=man share/ /c/mingw64/share/
- Edit /etc/fstab:
#Win64_Path Mount_Point C:/mingw64/ /mingw
Re-run C:\ming64\msys\msys.bat
0.1. More handy for the next steps (change "SRCDIR" and "MGWDIR" at your convenience):
    * export ARCH="x86_64-w64-mingw32"; export SRCDIR="/d/64/"; 
    * export MGWDIR="/c/mingw64/" (should be the same as given in /etc/fstab)
0.2. To find the include files ".h" added later on:
    * export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include
1.1. Intall libz [Source: http://zlib.net/zlib-1.2.8.tar.gz]
    - cd $SRCDIR"zlib-1.2.8"
    - patch win32/Makefile.gcc:
        patch win32/Makefile.gcc < ../fix-zlib-1.2.8-Makefile.gcc-mingw64.patch
    - make -f win32/Makefile.gcc
    - mkdir /usr/local/; mkdir /usr/local/bin ;mkdir /usr/local/include; mkdir /usr/local/lib;
    - cp zlib1.dll /usr/local/bin/zlib1.dll
    - cp zconf.h zlib.h /usr/local/include
    - cp libz.a /usr/local/lib
    - cp libz.dll.a /usr/local/lib/libz.dll.a
    - cp /usr/local/bin/zlib1.dll /usr/local/bin/libz.dll
1.2. Compile PostgreSQL-9.3.1 [Sources: http://ftp.postgresql.org/pub/source/v9.3.1/postgresql-9.3.1.tar.gz]
    * unzip postgresql-9.3.1.tar.gz
    * cd $SRCDIR"postgresql-9.3.1"
    * cp /usr/local/bin/libz.dll $MGWDIR$ARCH"/lib/"
    * ./configure --build=$ARCH --host=$ARCH --disable-float8-byval
        [--disable-float8-byval => required for compatibility with the installer provided by the official PostrgreSQL]
    * make
    * make install
        => install log:
            tout dans -> /usr/local/pgsql
    * Point to postgres utlities (pg_config.exe, ...):
        - export PATH=$PATH:/usr/local/pgsql/bin/
2.1 Compile Sqlite3 [Sources: http://www.sqlite.org/2013/sqlite-autoconf-3080100.tar.gz]
    * Download sqlite-autoconf-3080100.tar.gz (contains a "configure" script)
    * unzip
    * cd $SRCDIR"sqlite-autoconf-3080100"
    * ./configure --build=$ARCH --host=$ARCH
    * make 
    * make install
        => install log:
            sqlite3.h, sqlite3ext.h -> /usr/local/include
            libsqlite3-0.dll, sqlite3.exe -> /usr/local/bin
    * For MinGW to find the DLL while compiling "sqlite_fdw":
        - cp /usr/local/bin/libsqlite3-0.dll /usr/local/pgsql/lib/libsqlite3.dll
          [Think about removing the "-0"]
2.2 Compiling the extension sqlite_fdw
    * Get the source from SVN repository:
        - mkdir $SRCDIR"sqlite_fdw/"
        - cd $SRCDIR"sqlite_fdw"
        - svn checkout https://github.com/gleu/sqlite_fdw
    * cd $SRCDIR"sqlite_fdw/trunk"
    * make
    * make install
        => Install log:
            sqlite_fdw.dll -> /usr/local/pgsql/lib
            sqlite_fdw.control -> /usr/local/pgsql/share/extension
            sql/sqlite_fdw--0.0.1.sql -> /usr/local/pgsql/share/extension
            doc/sqlite_fdw.md -> /usr/local/pgsql/share/doc/extension
3. Compiling the extension www_fdw
- 
Install iconv [Sources: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz] * cd $SRCDIR"libiconv-1.14" * ./configure --build=$ARCH --host=$ARCH * make * make install
- 
Install libxml2 [Sources: ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz] * cp $WINDIR"/Sysnative/ws2_32.dll" $MGWDIR$ARCH"/lib/libws2_32.dll" ("System32" - 'Sysnative' being a redirection - is the place where 64-bit versions of the libraries are located) [http://stackoverflow.com/q/20188451/1715716] * cd $SRCDIR"libxml2-2.9.1" * Adding Python 2.7 support: - Get the "opt" directory from "x64-4.8.0-release-win32-seh-rev2.7z" to "/c/mingw64"- Patch by hand the very first line of "python2.7-config", "python-config" and "python2-config" into: #!/c/mingw64/opt/bin/python2.7.exe => OR, use the patch (which assumes msys's "fstab" was set correctly): - cd $MGWDIR"opt/bin/" - cp $SRCDIR/python-confg-files-64.patch ./ - patch -p1 < python-confg-files-64.patch - rm python-confg-files-64.patch - cp $MGWDIR"opt/bin/libpython2.7.dll" $MGWDIR$ARCH"/lib/" - Apply patch to the originzal "configure" script of libxml2-2.9.1 patch configure < ../fix-libxml2-2.9.1-configure-mingw64.patch * ./configure --build=$ARCH --host=$ARCH --with-zlib="/usr/local/" --with-iconv="/usr/local/" --with-python=$MGWDIR"opt/" * export C_INCLUDE_PATH=$C_INCLUDE_PATH:$MGWDIR"opt/include/python2.7/" * export LIBS="-lpython2.7"; export LDFLAGS="-L"$MGWDIR"opt/bin/" * make * make install * cp /usr/local/bin/libxml2-2.dll /usr/local/pgsql/lib/libxml2.dll [Think about removing the "-2"] * export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include/libxml2
- 
Install OpenSSL [Sources: http://www.openssl.org/source/openssl-1.0.1e.tar.gz] - cd $SRCDIR"openssl-1.0.1e" - Required patch: http://www.linuxfromscratch.org/patches/blfs/svn/openssl-1.0.1e-fix_parallel_build-1.patch - Required patch: http://www.linuxfromscratch.org/patches/blfs/svn/openssl-1.0.1e-fix_pod_syntax-1.patch - patch -Np1 -i ../openssl-1.0.1e-fix_parallel_build-1.patch && patch -Np1 -i ../openssl-1.0.1e-fix_pod_syntax-1.patch - perl Configure mingw64 shared zlib-dynamic no-asm - make depend - make - make install
- 
Install curl [Sources: http://curl.haxx.se/download/curl-7.33.0.tar.gz] - cd $SRCDIR"curl-7.33.0/" - ./configure --build=$ARCH --host=$ARCH --with-ssl="/usr/local/ssl" --with-zlib="/usr/local/" >> configure output: Configured to build curl/libcurl: curl version: 7.33.0 Host setup: x86_64-w64-mingw32 Install prefix: /usr/local Compiler: x86_64-w64-mingw32-gcc SSL support: enabled (OpenSSL) SSH support: no (--with-libssh2) zlib support: enabled GSSAPI support: no (--with-gssapi) SPNEGO support: no (--with-spnego) TLS-SRP support: enabled resolver: default (--enable-ares / --enable-threaded-resolver) ipv6 support: no (--enable-ipv6) IDN support: no (--with-{libidn,winidn}) Build libcurl: Shared=yes, Static=no Built-in manual: enabled --libcurl option: enabled (--disable-libcurl-option) Verbose errors: enabled (--disable-verbose) SSPI support: no (--enable-sspi) ca cert bundle: no ca cert path: no LDAP support: enabled (winldap) LDAPS support: enabled RTSP support: enabled RTMP support: no (--with-librtmp) metalink support: no (--with-libmetalink) HTTP2 support: disabled (--with-nghttp2) Protocols: DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SMTP SMTPS TELNET TFTP - make - make install - cp /usr/local/bin/libcurl-4.dll /usr/local/pgsql/lib/libcurl.dll [Think about removing "-4"]
- 
Get the source from SVN repository - mkdir $SRCDIR"www_fdw/" - cd $SRCDIR"www_fdw" - svn checkout https://github.com/gleu/www_fdw
- 
Patch source file $SRCDIR"www_fdw/trunk/src/utils.h" - patch trunk/src/utils.h < ../fix-www_fdw-utils.h-mingw64.patch
- 
Build * cd $SRCDIR"www_fdw/trunk" * make * make install => Install log: www_fdw.dll -> /usr/local/pgsql/lib www_fdw.control -> /usr/local/pgsql/share/extension sql/www_fdw--0.1.6.sql -> /usr/local/pgsql/share/extension
Testing the extensions (Windows Prompt):
1. Add "C:\mingw64\msys\local\pgsql\bin" and "C:\mingw64\msys\local\pgsql\lib" to $PATH 2. Add "C:\mingw64\msys\local\bin" to $PATH (accessing "libsqlite3-0.dll", "sqlite3.exe") 3. Add "C:\mingw64\msys\bin" to $PATH (accessing "msys-iconv-2.dll", "msys-1.0.dll")
4. Initialize the "data" (database) directory for the server:
    * cd C:\mingw64\msys\local\pgsql\
    * bin\initdb -Ddata
5. Start the PostgreSQL server:
    * bin\postgres -Ddata
6. Create the superuser and role "postgres" (asking for password)
    * bin\createuser -s -r -W postgres
7.1. Creating and testing the sqlite_fdw extension (depends on sqlite3.dll):
    * CREATE EXTENSION sqlite_fdw;
    * cd D:\postgresql-test-extensions
    * Create a sqlite database (file "test.db")
        [or use the one I provide]
        - cd /usr/local/bin
        - sqlite3 "test.db"
                SQLite version 3.8.1 2013-10-17 12:57:35
                Enter ".help" for instructions
                Enter SQL statements terminated with a ";"
                sqlite> create table tbl1(one varchar(10), two smallint);
                sqlite> insert into tbl1 values('hello!',10);
                sqlite> insert into tbl1 values('goodbye', 20);
                sqlite> select * from tbl1;
                hello!|10
                goodbye|20
                sqlite>
    * Into the "postgres" database, create the sqlite server:
        CREATE SERVER sqlite_server
          FOREIGN DATA WRAPPER sqlite_fdw
          OPTIONS (database 'D:\postgresql-test-extxtensions\test.db'); /* adapt to your config. */
    * Mapping between "tbl1" (sqlite DB) and the new "local_tbl1"
        CREATE FOREIGN TABLE local_tbl1(one varchar(10), two smallint)
          SERVER sqlite_server
          OPTIONS (table 'tbl1');
    * Executing a request:
        SELECT * from local_tbl1;
7.2. Creating and testing the extension www_fdw (depends on iconv.dll and libxml2.dll)
    * CREATE EXTENSION www_fdw;
    * Create a server (example with a "google search" one...):
        [Example grabbed from: https://github.com/cyga/www_fdw/wiki/Examples]
        CREATE SERVER www_fdw_google_search_server FOREIGN DATA WRAPPER www_fdw 
            OPTIONS (
                uri 'https://ajax.googleapis.com/ajax/services/search/web?v=1.0',
                cainfo 'C:\mingw64\msys\local\share\curl\curl-ca-bundle.crt'
                );
        /* Adapt "cainfo" option to your config. The path MUST be written the Windows way */
        CREATE USER MAPPING FOR current_user SERVER www_fdw_google_search_server;
        CREATE FOREIGN TABLE www_fdw_google_search (
          title text,
          link text,
          snippet text,
          q text /* used for easy query specifying */
        ) SERVER www_fdw_google_search_server;
        Note:   "curl --with-ssl" (the default) requiring a certificate, 
        -----   this example only works if we specify the "cainfo" option 
                (".crt" certificate file)
    * Request:
        SELECT title,snippet FROM www_fdw_google_search WHERE q='cat dog' LIMIT 3;
PATH environment variable:
    C:\mingw64\bin;
    C:\mingw64\lib;
    C:\mingw64\msys\local\pgsql\bin;
    C:\mingw64\msys\local\pgsql\lib;
    C:\mingw64\msys\local\bin;
    C:\mingw64\msys\bin;
    C:\mingw64\msys\local\ssl\bin;
    C:\mingw64\x86_64-w64-mingw32\bin;
    C:\mingw64\x86_64-w64-mingw32\lib;
    C:\mingw64\opt\bin;
=>
    SET PATH=%PATH%;C:\mingw64\bin;C:\mingw64\lib;C:\mingw64\x86_64-w64-mingw32\bin;C:\mingw64\msys\local\pgsql\bin;C:\mingw64\msys\local\pgsql\lib;C:\mingw64\msys\local\bin;C:\mingw64\msys\bin;C:\mingw64\msys\local\ssl\bin;C:\mingw64\x86_64-w64-mingw32\lib;C:\mingw64\opt\bin;
OR, using MSYS:
    export PATH=$PATH:$MGWDIR"bin":$MGWDIR"lib":$MGWDIR$ARCH"/bin:/usr/local/pgsql/bin":/usr/msys/local/pgsql/lib:/usr/local/bin:/usr/bin:/usr/local/ssl/bin:$MGWDIR$ARCH"/lib":$MGWDIR"opt/bin"
TODO: create a ".sh" script that builds the standalone version from the mingw-32/64's install directory. (Identical script for both 32 and 64-bit versions using the environment variables: $ARCH, $SRCDIR and $MGWDIR)