Introduction to Postgresql Database 12-Installation

 Install with source code under WINDOWS

For most ordinary users who need to install PostgreSQL under windows, it is recommended to download the one-click installation package from the official website for installation. The source code installation is mainly for PostgreSQL developers, or developers of PostgreSQL related extensions.

There are many ways to build, compile and install PostgreSQL in Windows. For Microsoft tools, the easiest way to compile is to install the latest version of the Microsoft platform SDK and use its own compiler to compile. You can also use Visual C++2005 or 2008 to compile and install. In some cases, the SDK platform must be installed in addition to the compiler.

It is also possible to build PostgreSQL using the GNU compiler tools provided by MinGW, or using Cygwin for older versions of Windows.

You can also use the GNU compiler in MinGW to compile PostgreSQL. If the version of windows is older, you can use the compilation tool under Cygwin.

Finally, the client access library (libpq) can be built using Visual C++ 7.1 or Borland C++ for compatibility with statically linked applications built using these tools.

Finally, in order to be compatible with statically linked libpq applications, you can use Visual C++ 7.1 or Borland C++ to compile libpq.

Building using MinGW or Cygwin uses the normal build system, see Chapter 15 and the specific notes in Section 15.7.5 and Section 15.7.2. To produce native 64 bit binaries in these environments, use the tools from MinGW-w64. These tools can also be used to cross-compile for 32 bit and 64 bit Windows targets on other hosts, such as Linux and Darwin. Cygwin is not recommended for running a production server, and it should only be used for running on older versions of Windows where the native build does not work, such as Windows 98. The official binaries are built using Visual Studio.

If you use the general compilation system of MinGW or Cygwin, please refer to Chapter 15, Section 15.7.5 and Section 15.7.2 for related instructions. To generate native 64-bit executable programs in these environments, you can use the tools included in MinGW-w64. These tools can also perform cross-compilation under 32-bit and 64-bit windows to generate and compile executable programs under cross-platforms such as Linux and Darwin. The Cygwin platform is not recommended for servers in a production environment. It is only suitable for use when the system's compiler cannot compile on older versions of windows such as Windows 98. The official binary executable file is compiled with Visual Studio.


Native builds of psql don't support command line editing. The Cygwin build does support command line editing, so it should be used where psql is needed for interactive use on Windows.

The native psql executable program does not support command line editing, and the executable file compiled under Cygwin supports command line editing, so if you want to use interactive psql in a window environment, it is best to use Cygwin compilation.

1 Created with Visual C++ or SDK platform

PostgreSQL can use Microsoft's Visual C++ compiler suite to create compilations. These compilers can be Visual Studio, Visual Studio Express, or some versions of Platform SDK. If you haven't configured the Visual Studio environment, the easiest way is to use the SDK platform compiler, which can be downloaded for free from Microsoft's official website.

PostgreSQL supports the compilers of Visual Studio 2005 and Visual Studio 2008. When you only use Platform SDK or want to compile the 64-bit Windows version, only the Visual Studio 2008 compiler is supported. Visual Studio 2010 does not yet support the compilation of PostgreSQL on the Windows platform.

Tools created with Visula C++ are in the directory src/tools/msvc. When compiling, make sure that no MinGW or Cygwin tools appear in your system path, and also make sure that all required Visual C++ tools are in your path. Available. In Visual Studio, start the Visual Studio command prompt. In the SDK platform, start the CMD shell listed in the start menu. If you want to compile a 64-bit version, you must use the 64-bit version of the command. All commands should be run from the src\tools\msvc directory.

Before you compile, you may need to edit the config.pl file to reflect any configuration options you want to change, or specify the path to another library to be used. The complete configuration is determined by the file config_default.pl that is read and parsed for the first time, and applied to any changes from config.pl. For example, to specify the location of your Python installation, put the following statement in the config.pl file:

 $config->{python} = 'c:\python26';  

You only need to specify the parameters that are different from those in the config_default.pl file.

If you need to set any other environment variables, create a file called buildenv.pl and put the required commands in it. For example, to add a path to bison, create a file containing:

 $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';  

1.1 Requirements

To build and compile PostgreSQL, the following additional tools are needed. Use the file config.pl to specify the directory where each library is located.

Platform SDK for Microsoft platform

It is recommended that you upgrade the Microsoft Platform SDK to the latest version (the latest version is 7.0), which can be downloaded from the website http://www.microsoft.com/downloads/.

You must always keep the Windows header files in the SDK and some libraries of the SDK. If the Platform SDK you installed already includes the Visual C++ compiler, you do not need to use Visual Studio to compile.

ActiveState Perl

ActiveState Perl is used to run the compilation and generation scripts, but Perl in MinGW or Cygwin cannot. The path where Perl is located must be placed in the path PATH environment variable. Binary can be downloaded from http://www.activestate.com (note: version 5.8 or newer is required, free standard package is sufficient)

The following additional products are not required before starting, but are required when compiling the complete package. Use the config.pl file to specify the available directory of the library.

ActiveState TCL

Used to compile PL/TCL (note: version 8.4 is required, free standard package is sufficient)

Bison and Flex

Bison and Flex are used to compile from Git, but they are not needed when compiling a distribution file. Note that Bison is only available with version 1.875 or 2.2 or higher. Similarly, Flex requires version 2.5.31 or higher. Bison can be downloaded from http://gnuwin32.sourceforge.net, and Flex can be downloaded from http://www.postgresql.org/ftp/misc/winflex/.

Diff

Diff is required for running regression tests and can be downloaded from http://gnuwin32.sourceforge.net

Gettext

Gettext is required for compiling with NLS support and can be downloaded from http://gnuwin32.sourceforge.net. Note: Binary, management and development files are all required.

WITH Kerberos

To support Kerberos authentication required, MIT Kerberos can be downloaded from http://web.mit.edu/Kerberos/dist/index.html.

libxml2 and libxslt

To support XML, the binary file can be downloaded from http://zlatkovic.com/pub/libxml or the source file http://xmlsoft.org. Note: iconv is required for libxml2, which can be obtained from the same download location.

openssl

To support SSL, the binary file can be downloaded from http://www.slproweb.com/products/Win32OpenSSL.html or the source file http://www.openssl.org.

ossp-uuid

To support UUID-OSSP, the source files can be downloaded from http://www.ossp.org/pkg/lib/uuid/

Python

To compile PL/Python, the binary file can be downloaded from http://www.python.org.

zlib

To support compression into pg_dump and pg_restore, binary files can be downloaded from http://www.zlib.net.

1.2 Special considerations for 64-bit windows

PostgreSQL will only be compiled for the x64 architecture of 64-bit windows, it does not support itanium processors.

Mixed 32- and 64-bit version systems are not supported under the same build tree. If it is in these environments, the build system will automatically discover and compile accordingly. For this reason, it is important to start the correct command before compiling.

To use a server-side third-party library, such as python or openssl, the library must be 64-bit. There is no support for downloading 32-bit libraries on 64-bit servers. Only a few third-party libraries supported by PostgreSQL can be used in 32-bit. In this case, they cannot be used in 64-bit PostgreSQL.

1.3 Compile

To compile all distributions configured PostgreSQL (default), run the command

build

To compile all PostgreSQL in debug configuration, run the command

build DEBUG

Only compile a single project, such as psql, run the command

build psql
build DEBUG psql

To change the default compilation configuration to debug configuration, put the following statement in the buildenv.pl file

$ENV{CONFIG}="Debug";

It is also possible to compile the configuration in the Visual Studio GUI. In this case, you need to run from the command prompt

perl mkvcbuild.pl

Then open the generated file pgsql.sln (under the root directory of the source tree) in Visual Studio.

1.4 Clean and install

In most cases, the automatic dependency footprint in Visual Studio will handle the changed files, but if there are major changes, you may want to clean the installation. To do this, simply run the clean.bat command, it All generated files will be cleared automatically. You can also run the dist parameter, in this case it will be similar to make distclean and also remove the flex/bison output file.

By default, all files are written to a subdirectory of the debug or release directory. To install these files using standard settings, initialize these generated files and use the database, run the command:

install c:\destination\directory

1.5 Run regression tests

To run the regression test, you must first make sure that you have completed the required parts of the compilation, and make sure that the DLLs used to load all parts of the system are in the system path. If not, set it through the buildenv.pl file. To run the test, run one of the following commands in the directory src\tools\msvc

vcregress check
vcregress installcheck
vcregress plcheck
vcregress contribcheck

To change the scheduler used (default is parallel), add it to the command line:

vcregress check serial

For more information about regression testing, see Chapter 30.

1.6 Compile files

Compiling PostgreSQL files in HTML format requires several tools and files. Create a new root directory for all these files and save them in the subdirectories listed below.

OpenJade 1.3.1-2

Download from http://sourceforge.net/projects/openjade/files/openjade/1.3.1/openjade-1_3_1-2-bin.zip/download, unzip it to the subdirectory openjade-1.3.1

DocBook DTD 4.2

Download it from http://www.oasis-open.org/docbook/sgml/4.2/docbook-4.2.zip and unzip it to the docbook subdirectory.

DocBook DSSSL 1.79

Download it from http://sourceforge.net/projects/docbook/files/docbook-dsssl/1.79/docbook-dsssl-1.79.zip/download and unzip it to the docbook-dsssl-1.79 subdirectory.

ISO character entities

Download it from http://www.oasis-open.org/cover/ISOEnts.zip and unzip it to the docbook subdirectory.

Edit the buildenv.pl file and add a variable to the location of the root directory, for example

$ENV{DOCROOT}='c:\docbook';

To build the documentation, run the command builddoc.bat. Note that this will actually run the build twice, in order to generate the indexes. The generated HTML files will be in doc\src\sgml. To build the file, run the command builddoc. bat. Note that in order to generate the index, the compilation will actually be run twice. The generated HTML file will be in the directory doc\src\sgml.

2 Compile libpq with Visual C++ or Borland C++

If you need a version with different debug/release flags or a static library to connect to an application, it is only recommended that you use Visual C++ 7.1-9.0 or Borland C++ to compile libpq. Generally, it is recommended to use MinGW or Visual Studio or SDK platform method. Use Visual Studio 7.1 or higher to compile the libpq client library, change the src directory and type the command:

nmake / f win32.mak

Use Visual Studio 8.0 or higher to create a 64-bit libpq client library, change the src directory and type the command:

nmake /f win32.mak CPU=AMD64

Refer to the win32.mak file for more details on the supported variables.

Use Borland C++ to compile the libpq client library, change the src directory and type the command:

make -N -DCFG=Release /f bcc32.mak

2.1 Generate files

The following files will be compiled:

interfaces\libpq\Release\libpq.dll

Dynamically connectable front-end library

interfaces\libpq\Release\libpqdll.lib

Link your program to the important library of libpq.dll

interfaces\libpq\Release\libpq.lib

Static version of the front-end library

Usually you do not need to install any client file, you should put the libpq.dll file and your application executable file in the same directory. Unless absolutely necessary, do not install libpq.dll into your windows, System or System32 directory. If the file is installed with the installer, then it should be checked with versioninfo before installation to ensure that the new version of the library will not be overwritten.

If you plan to develop on this machine, you must add the subdirectories src\include and src\interfaces\libpq to the include path.

To use the library, you must add libpqdll.lib to your project. (In Visual C++, just right-click on the project and choose Add.)

Guess you like

Origin blog.csdn.net/qq_37061368/article/details/113242831
Recommended