1. Source Code download and preparation
PostgreSQL uses the flex and yacc scripts respectively for lexical and Syntax Parsing, that is, the. l and. y files in the source code are generated by them. c and. H files.
For more details, see:
Http://flex.sourceforge.net/(unfortunately, this website cannot be accessed directly and you can find a solution)
Http://www.gnu.org/software/bison/
These two tools have not been completely completed in the Windows environment. In addition, considering their versions, I generate a syntax engine in Linux. For the operation steps, see (2 ).
References: Mechanical Industry Press of lex and yacc
(1) download the package. The advantage of this method is that you do not need to use flex and bison.
:
International community http://www.postgresql.org/ftp/source/
Domestic image ftp://www.highgo.com.cn/pub/mirrors/pgsql/source/
In step 2, you do not need to generate any files in Linux.
(2) The clone community git code library requires: git flex bison
Git is a powerful and confusing code management tool. Learn how to use it on the official website:
Http://git-scm.com/(still unfortunately, find a solution on your own)
In Windows, Cygwin can be installed, git and openssh can be installed, and git can be used in the Cygwin environment.
Http://www.cygwin.com
Note that the compilation switch must be consistent. The following steps a-e must be executed in Linux.
A). Clone the code library
Git clone http://git.postgresql.org/git/postgresql.git
B). To configure compilation parameters, you may need to install some Development kits and install them according to the error prompt.
./Configure -- prefix =/usr/local/pg93b1 \
-- Enable-nls = "zh_CN zh_TW "\
-- Without-perl \
-- Without-python \
-- Without-tcl \
-- Without-gssapi \
Without-krb5 \
-- Without-pam \
-- Without-ldap \
-- Without-bonjour \
-- With-openssl \
-- With-libxml -- with-libxslt \
-- Enable-thread-safety \
-- With-zlib \
-- Without-selinux
C) Compile the kernel
Make
D) Compile the peripheral modules.
Cd contrib & make
Cd ..
E) Compile the isolation test script
Cd src/test/isolation & make
F) copy the following file to the same location of the source code in Windows.
Src \ backend \ bootstrap \ bootparse. c
Src \ backend \ bootstrap \ bootpattern. c
Src \ backend \ parser \ gram. c
Src \ backend \ parser \ gram. h
Src \ backend \ parser \ scan. c
Src \ backend \ replication \ repl_gram.c
Src \ backend \ replication \ repl_scanner.c
Src \ backend \ utils \ misc \ guc-file.c
Src \ bin \ psql \ psqlscan. c
Contrib \ cube \ cubeparse. c
Contrib \ cube \ cubescan. c
Contrib \ seg \ segparse. c
Contrib \ seg \ segscan. c
Src \ interfaces \ ecpg \ preproc \ pgc. c
Src \ interfaces \ ecpg \ preproc. c
Src \ interfaces \ ecpg \ preproc. h
Src \ pl \ plpgsql \ src \ pl_gram.c
Src \ pl \ plpgsql \ src \ pl_gram.h
Src \ test \ isolation \ specparse. c
Src \ test \ isolation \ specw.c
2. Download and prepare Windows Development Kit
For the list of Development kits required for compiling PostgreSQL in Windows, see 16.1.1. Requirements.
Http://slproweb.com/products/Win32OpenSSL.html
Download OpenSSL, which is comprehensive here.
Ftp://ftp.zlatkovic.com/libxml/
Openssl is also available here, but the version is old.
Download iconv, libxml2, libxslt, and zlib from here. We recommend that you use
Http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/
Download gettext here
The package updates on the http://gnuwin32.sourceforge.net/mentioned in the document are far behind gnu, but still available.
Decompress the downloaded package to the c: \ pgbuild directory.
3. Download from Microsoft VC. The express version is sufficient for us and is free of charge.
Http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products
After installation, we recommend that you install all patches.
4. Modify src \ tools \ msvc \ config_default.pl to point to the downloaded SDK.
Nls => "C: \ pgbuild \ gettext"
Openssl => "C: \ pgbuild \ OpenSSL"
Xml => "C :\\ pgbuild \ libxml2"
Xslt => "C :\\ pgbuild \ libxslt"
Iconv => "C: \ pgbuild \ iconv"
Zlib => "C: \ pgbuild \ zlib"
6. Download and install ActivePerl
Http://www.activestate.com/activeperl
7. Open the program menu "Microsoft Visual Studio 2010"-> "Visual Studio Tools"-> "Visual Studio Command Prompt (2010)"
If it is another version, it should be noted that it is a 32-bit version, but you cannot be sure of its attributes. The parameter x86 is behind vcvarsall. bat.
Set path = % path %; C: \ pgbuild \ iconv \ bin;
Set path = % path % C: \ ActivePerl-5.12.x \ bin;
Set path = % path % C: \ pgbuild \ gettext \ bin;
Go to the PostgreSQL source code src \ tools \ msvc and run build. bat.
Run after compilation: install. bat <target directory>
8. At this point, the compilation is complete, but some dll files need to be manually copied. Find the dll files in the Development Kit directory in step 2 based on the file missing error prompt.