Postgresql 中文操作指南

Chapter 18. Installation from Source Code on Windows

Table of Contents

建议大多数用户下载 Windows 的二进制发行版,该发行版作为 PostgreSQL 网站 https://www.postgresql.org/download/ 上的图形安装程序包提供。仅打算构建源代码以开发 PostgreSQL 或扩展。

It is recommended that most users download the binary distribution for Windows, available as a graphical installer package from the PostgreSQL website at https://www.postgresql.org/download/. Building from source is only intended for people developing PostgreSQL or extensions.

有几种不同的方法可以在 Windows 上构建 PostgreSQL。使用 Microsoft 工具构建的最简单方法是安装 Visual Studio 2022 并使用附带的编译器。也可以使用完整的 Microsoft Visual C++ 2015 至 2022 构建。在某些情况下,除了编译器之外,还需要安装 Windows SDK。

There are several different ways of building PostgreSQL on Windows. The simplest way to build with Microsoft tools is to install Visual Studio 2022 and use the included compiler. It is also possible to build with the full Microsoft Visual C++ 2015 to 2022. In some cases that requires the installation of the Windows SDK in addition to the compiler.

还可以使用 MinGW 提供的 GNU 编译器工具或 Cygwin(适用于较旧版本的 Windows)来构建 PostgreSQL。

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

使用 MinGW 或 Cygwin 构建使用正常构建系统,请参见 Chapter 17 以及 Section 17.7.4Section 17.7.2 中的特定说明。要在这些环境中生成本机 64 位二进制文件,请使用 MinGW-w64 中的工具。这些工具还可用于在 Linux 和 macOS 等其他主机上交叉编译 32 位和 64 位 Windows 目标。不建议使用 Cygwin 来运行生产服务器,它只应在以下情况下使用:native 构建不起作用的较旧版本的 Windows 上。官方二进制文件使用 Visual Studio 构建。

Building using MinGW or Cygwin uses the normal build system, see Chapter 17 and the specific notes in Section 17.7.4 and Section 17.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 macOS. 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. The official binaries are built using Visual Studio.

psql 的 native 构建不支持命令行编辑。Cygwin 构建支持命令行编辑,因此应在 Windows 上需要交互式使用 psql 的地方使用它。

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.