As for me, using new MSYS2 building platform for Windows is a bless. With its help not only PostgreSQL sources are built smoothly, but even extensions are not a problem anymore. And if you were playing with extensions under Windows, you know what I’m talking about.
At its core MSYS2 is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.
After installation and upgrading run in cmd console
or simply just click on the Start menu “MSYS2 MinGW 64-bit” shortcut:
Then update packages:
Install only needed packages:
pacman --needed -S git mingw-w64-x86_64-gcc base-devel
Let’s build it!
Get the PostgreSQL sources. Here you have two options:
1. Download them from the official site.
2. Use git repository:
git clone git://git.postgresql.org/git/postgresql.git
Enter to the source folder:
And run configure followed by make and make install:
./configure --host=x86_64-w64-mingw32 --prefix=/c/pgsql/ && make && make install
Here we tell our target machine will be 64-bit and we want our binaries to be copied to C:\pgsql\.
As you may see building PostgreSQL with MSYS2 for Windows is simple enough. But the main profit of such toolchain is building extensions for PostgreSQL. And there it shines in all its glory. Stay tuned.