Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
18.1. Building withVisual C++ or theMicrosoft Windows SDK
Prev UpChapter 18. Installation from Source Code onWindowsHome Next

18.1. Building withVisual C++ or theMicrosoft Windows SDK#

PostgreSQL can be built using the Visual C++ compiler suite from Microsoft. These compilers can be either fromVisual Studio,Visual Studio Express or some versions of theMicrosoft Windows SDK. If you do not already have aVisual Studio environment set up, the easiest ways are to use the compilers fromVisual Studio 2022 or those in theWindows SDK 10, which are both free downloads from Microsoft.

Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite. 32-bit PostgreSQL builds are possible withVisual Studio 2015 toVisual Studio 2022, as well as standalone Windows SDK releases 10 and above. 64-bit PostgreSQL builds are supported withMicrosoft Windows SDK version 10 and above orVisual Studio 2015 and above.

The tools for building usingVisual C++ orPlatform SDK are in thesrc\tools\msvc directory. When building, make sure there are no tools fromMinGW orCygwin present in your system PATH. Also, make sure you have all the required Visual C++ tools available in the PATH. InVisual Studio, start theVisual Studio Command Prompt. If you wish to build a 64-bit version, you must use the 64-bit version of the command, and vice versa. Starting withVisual Studio 2017 this can be done from the command line usingVsDevCmd.bat, see-help for the available options and their default values.vsvars32.bat is available inVisual Studio 2015 and earlier versions for the same purpose. From theVisual Studio Command Prompt, you can change the targeted CPU architecture, build type, and target OS by using thevcvarsall.bat command, e.g.,vcvarsall.bat x64 10.0.10240.0 to target Windows 10 with a 64-bit release build. See-help for the other options ofvcvarsall.bat. All commands should be run from thesrc\tools\msvc directory.

Before you build, you can create the fileconfig.pl to reflect any configuration options you want to change, or the paths to any third party libraries to use. The complete configuration is determined by first reading and parsing the fileconfig_default.pl, and then apply any changes fromconfig.pl. For example, to specify the location of yourPython installation, put the following inconfig.pl:

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

You only need to specify those parameters that are different from what's inconfig_default.pl.

If you need to set any other environment variables, create a file calledbuildenv.pl and put the required commands there. For example, to add the path for bison when it's not in the PATH, create a file containing:

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

To pass additional command line arguments to the Visual Studio build command (msbuild or vcbuild):

$ENV{MSBFLAGS}="/m";

18.1.1. Requirements#

The following additional products are required to buildPostgreSQL. Use theconfig.pl file to specify which directories the libraries are available in.

Microsoft Windows SDK

If your build environment doesn't ship with a supported version of theMicrosoft Windows SDK it is recommended that you upgrade to the latest version (currently version 10), available for download fromhttps://www.microsoft.com/download.

You must always include theWindows Headers and Libraries part of the SDK. If you install aWindows SDK including theVisual C++ Compilers, you don't needVisual Studio to build. Note that as of Version 8.0a the Windows SDK no longer ships with a complete command-line build environment.

Strawberry Perl

Strawberry Perl is required to run the build generation scripts. MinGW or Cygwin Perl will not work. It must also be present in the PATH. Binaries can be downloaded fromhttps://strawberryperl.com.

The following additional products are not required to get started, but are required to build the complete package. Use theconfig.pl file to specify which directories the libraries are available in.

Magicsplat Tcl

Required for buildingPL/Tcl. Binaries can be downloaded fromhttps://www.magicsplat.com/tcl-installer/index.html.

Bison andFlex

Bison andFlex are required to build from Git, but not required when building from a release file. OnlyBison versions 2.3 and later will work.Flex must be version 2.5.35 or later.

BothBison andFlex are included in themsys tool suite, available fromhttp://www.mingw.org/wiki/MSYS as part of theMinGW compiler suite.

You will need to add the directory containingflex.exe andbison.exe to the PATH environment variable inbuildenv.pl unless they are already in PATH. In the case of MinGW, the directory is the\msys\1.0\bin subdirectory of your MinGW installation directory.

Note

The Bison distribution from GnuWin32 appears to have a bug that causes Bison to malfunction when installed in a directory with spaces in the name, such as the default location on English installationsC:\Program Files\GnuWin32. Consider installing intoC:\GnuWin32 or use the NTFS short name path to GnuWin32 in your PATH environment setting (e.g.,C:\PROGRA~1\GnuWin32).

Diff

Diff is required to run the regression tests, and can be downloaded fromhttp://gnuwin32.sourceforge.net.

Gettext

Gettext is required to build with NLS support, and can be downloaded fromhttp://gnuwin32.sourceforge.net. Note that binaries, dependencies and developer files are all needed.

MIT Kerberos

Required for GSSAPI authentication support. MIT Kerberos can be downloaded fromhttps://web.mit.edu/Kerberos/dist/index.html.

libxml2 andlibxslt

Required for XML support. Binaries can be downloaded fromhttps://zlatkovic.com/pub/libxml or source fromhttp://xmlsoft.org. Note that libxml2 requires iconv, which is available from the same download location.

LZ4

Required for supportingLZ4 compression. Binaries and source can be downloaded fromhttps://github.com/lz4/lz4/releases.

Zstandard

Required for supportingZstandard compression. Binaries and source can be downloaded fromhttps://github.com/facebook/zstd/releases.

OpenSSL

Required for SSL support. Binaries can be downloaded fromhttps://slproweb.com/products/Win32OpenSSL.html or source fromhttps://www.openssl.org.

ossp-uuid

Required for UUID-OSSP support (contrib only). Source can be downloaded fromhttp://www.ossp.org/pkg/lib/uuid/.

Python

Required for buildingPL/Python. Binaries can be downloaded fromhttps://www.python.org.

zlib

Required for compression support inpg_dump andpg_restore. Binaries can be downloaded fromhttps://www.zlib.net.

18.1.2. Special Considerations for 64-Bit Windows#

PostgreSQL will only build for the x64 architecture on 64-bit Windows.

Mixing 32- and 64-bit versions in the same build tree is not supported. The build system will automatically detect if it's running in a 32- or 64-bit environment, and build PostgreSQL accordingly. For this reason, it is important to start the correct command prompt before building.

To use a server-side third party library such asPython orOpenSSL, this librarymust also be 64-bit. There is no support for loading a 32-bit library in a 64-bit server. Several of the third party libraries that PostgreSQL supports may only be available in 32-bit versions, in which case they cannot be used with 64-bit PostgreSQL.

18.1.3. Building#

To build all of PostgreSQL in release configuration (the default), run the command:

build

To build all of PostgreSQL in debug configuration, run the command:

build DEBUG

To build just a single project, for example psql, run the commands:

build psqlbuild DEBUG psql

To change the default build configuration to debug, put the following in thebuildenv.pl file:

$ENV{CONFIG}="Debug";

It is also possible to build from inside the Visual Studio GUI. In this case, you need to run:

perl mkvcbuild.pl

from the command prompt, and then open the generatedpgsql.sln (in the root directory of the source tree) in Visual Studio.

18.1.4. Cleaning and Installing#

Most of the time, the automatic dependency tracking in Visual Studio will handle changed files. But if there have been large changes, you may need to clean the installation. To do this, simply run theclean.bat command, which will automatically clean out all generated files. You can also run it with thedist parameter, in which case it will behave likemake distclean and remove the flex/bison output files as well.

By default, all files are written into a subdirectory of thedebug orrelease directories. To install these files using the standard layout, and also generate the files required to initialize and use the database, run the command:

install c:\destination\directory

If you want to install only the client applications and interface libraries, then you can use these commands:

install c:\destination\directory client

18.1.5. Running the Regression Tests#

To run the regression tests, make sure you have completed the build of all required parts first. Also, make sure that the DLLs required to load all parts of the system (such as the Perl and Python DLLs for the procedural languages) are present in the system path. If they are not, set it through thebuildenv.pl file. To run the tests, run one of the following commands from thesrc\tools\msvc directory:

vcregress checkvcregress installcheckvcregress plcheckvcregress contribcheckvcregress modulescheckvcregress ecpgcheckvcregress isolationcheckvcregress bincheckvcregress recoverycheckvcregress taptest

To change the schedule used (default is parallel), append it to the command line like:

vcregress check serial

vcregress taptest can be used to run the TAP tests of a target directory, like:

vcregress taptest src\bin\initdb\

For more information about the regression tests, seeChapter 33.

Running the regression tests on client programs withvcregress bincheck, on recovery tests withvcregress recoverycheck, or TAP tests specified withvcregress taptest requires an additional Perl module to be installed:

IPC::Run

As of this writing,IPC::Run is not included in the ActiveState Perl installation, nor in the ActiveState Perl Package Manager (PPM) library. To install, download theIPC-Run-<version>.tar.gz source archive fromCPAN, athttps://metacpan.org/dist/IPC-Run, and uncompress. Edit thebuildenv.pl file, and add a PERL5LIB variable to point to thelib subdirectory from the extracted archive. For example:

$ENV{PERL5LIB}=$ENV{PERL5LIB} . ';c:\IPC-Run-0.94\lib';

The TAP tests run withvcregress support the environment variablesPROVE_TESTS, that is expanded automatically using the name patterns given, andPROVE_FLAGS. These can be set on a Windows terminal, before runningvcregress:

set PROVE_FLAGS=--timer --jobs 2set PROVE_TESTS=t/020*.pl t/010*.pl

It is also possible to set up those parameters inbuildenv.pl:

$ENV{PROVE_FLAGS}='--timer --jobs 2'$ENV{PROVE_TESTS}='t/020*.pl t/010*.pl'

Additionally, the behavior of TAP tests can be controlled by a set of environment variables, seeSection 33.4.1.

Some of the TAP tests depend on a set of external commands that would optionally trigger tests related to them. Each one of those variables can be set or unset inbuildenv.pl:

GZIP_PROGRAM

Path to agzip command. The default isgzip, which will search for a command by that name in the configuredPATH.

LZ4

Path to alz4 command. The default islz4, which will search for a command by that name in the configuredPATH.

OPENSSL

Path to anopenssl command. The default isopenssl, which will search for a command by that name in the configuredPATH.

TAR

Path to atar command. The default istar, which will search for a command by that name in the configuredPATH.

ZSTD

Path to azstd command. The default iszstd, which will search for a command by that name in the configuredPATH.


Prev Up Next
Chapter 18. Installation from Source Code onWindows Home Chapter 19. Server Setup and Operation
pdfepub
Go to PostgreSQL 16
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp