Skip to content

Build PostgreSQL

David  Li edited this page Apr 28, 2019 · 2 revisions

Build on Ubuntu 18.04

Reference:Installation from Source Code

Requisites:

  • gcc sudo apt install gcc g++
  • make sudo apt install make
  • bison/flex sudo apt install bison flex
  • zlib sudo apt install zlib1g-dev
  • libedit-dev (BSD-license replacement of readline) sudo apt install libedit-dev

Checkout PostgreSQL 11.2:

git clone https://github.com/davidli2010/postgresql-11.2.git

Build DEBUG:

cd postgresql-11.2
chmod +x ./configure
./configure --with-libedit-preferred --enable-debug --enable-cassert --enable-depend --prefix=</path/to/install> CFLAGS=-O0
make install -j 4

Create test database:

cd </path/to/install>/bin
./initdb -D ../data
./postgres -D ../data >logfile 2>&1 &
./createdb test
./psql test

Build on Windows

See also https://www.cnblogs.com/baisha/p/7829028.html.

Reference:Building with Visual C++ or the Microsoft Windows SDK

Requisites:

Checkout PostgreSQL 11.2:

git clone https://github.com/davidli2010/postgresql-11.2.git

MSVC build scripts is modified to suppport Visual Studio 2019 in commit a8eb92b5.

Use x64 Native Tools Command Prompt for VS 2019 command line to build.

Build DEBUG:

cd postgresql-11.2\src\tools\msvc
build DEBUG
vcregress check
install <\path\to\install>

Create test database:

cd <\path\to\install>
initdb -D ../data
pg_ctl -D ../data -l logfile start
createdb test
psql test
Clone this wiki locally