当前位置: 首页 > news >正文

windows 上编译PostgreSQL

在windows上编译PG,编译器可以使用vs和MinGW的gcc进行编译。

编译前准备:

Microsoft Windows SDK

Strawberry Perl   //提供Perl的支持,内部还包括gcc

Bison和Flex(不同的PG需要不通的版本,具体需要查看帮助文档)

安装Bison和Flex目录不要选择默认的c:\program files,因为目录中间有空格,后续编译会报错,PG的文档中有记录,建议安装在没有空格的目录中,比如c:\GnuWin32目录中

可以使用win_bison.exe和win_flex.exe

工程构造工具以及编译步骤

PG16之前,包括16,使用Perl进行项目构造后进行编译,具体配置信息在src/tools/msvc目录中。

具体步骤:

1. 安装vs的community版本。

2. 开始菜单,选择VS -> X64 native command tools  

3. cd进入src/tools/msvc

4. 执行build configuration component 

build release psql (编译plsq的release版本)  默认编译文件放在release目录中

build debug (编译所有的debug版本) ,默认编译文件放在Debug目录中

同时会在msvc目录中创建一个pgsql.sln工程文件,可以直接使用vs打开后进行编译。

5. 如果需要添加组件,比如支持openSSL,libxml等等,可以打开

msvc目录中的config_deafult.pl文件,添加相应的组件,如下面的内容,我添加了对Openssl和iconv的支持


# Copyright (c) 2021-2023, PostgreSQL Global Development Group# Configuration arguments for vcbuild.
use strict;
use warnings;our $config = {asserts => 0,    # --enable-cassert# blocksize => 8,         # --with-blocksize, 8kB by default# wal_blocksize => 8,     # --with-wal-blocksize, 8kB by defaultldap => 1,             # --with-ldapextraver => undef,     # --with-extra-version=<string>gss => undef,          # --with-gssapi=<path>icu => undef,          # --with-icu=<path>lz4 => undef,          # --with-lz4=<path>zstd => undef,         # --with-zstd=<path>nls => undef,          # --enable-nls=<path>tap_tests => undef,    # --enable-tap-teststcl => undef,          # --with-tcl=<path>perl => undef,         # --with-perl=<path>python => undef,       # --with-python=<path>openssl => 'C:\Program Files\OpenSSL-Win64',      # --with-ssl=openssl with <path>uuid => undef,         # --with-uuid=<path>xml => undef,          # --with-libxml=<path>xslt => undef,         # --with-libxslt=<path>iconv => 'C:\Program Files\GnuWin32',        # (not in configure, path to iconv)zlib => undef           # --with-zlib=<path>
};

6. 编译完后,使用install target_dir install_type进行安装

PG16除了可以使用Perl进行项目的构建,还增加了meson进行项目的构建

PG17以及之后,就只能使用meson进行项目的构建(src/tools/msvc目录已经没有了)

meson构建项目步骤

1. 安装meson,具体安装查看帮助

2. 进入到PG源码的根目录下,执行

 meson setup build --prefix=targetdir --buildtype=debug|release -Dssl=openssl 

 (类似./configure --prefix=targetdir --with-openssl --enable-debug)

3. cd build

3. ninja 进行编译(默认使用gcc进行编译,因为Strawberry Perl 带着 gcc和g++编译器)

4.ninja install 安装

5. 也可以使用vs进行编译,方法如下

1. mesa setup build_debug --backend=vs2022 --prefix=targetdir --buildtype=debug -Dssl=openssl  //编译debug版本

2. cd build

(arcgispro-py3) D:\info\postgresql\postgresql-17.5\build>meson compile
INFO: autodetecting backend as vs2022
INFO: calculating backend command to run: msbuild D:\info\postgresql\postgresql-17.5\build\postgresql.sln -maxCpuCount -verbosity:minimal
适用于 .NET Framework MSBuild 版本 17.13.19+0d9f5a35a

3. meson compile

4. meson build

http://www.xdnf.cn/news/1262719.html

相关文章:

  • 客户端攻击防御:详解现代浏览器安全措施
  • 【unitrix数间混合计算】2.4 二进制整数标准化处理(src/number/normalize/int_normalize.rs)
  • seo-使用nuxt定义页面标题和meta等信息
  • Nearest Smaller Values(sorting and searching)
  • 3-防火墙
  • 2025年最新Java后端场景题+八股文合集(100w字面试题总结)
  • 华清远见25072班C语言学习day5
  • 基于Spring Boot的Minio图片定时清理实践总结
  • Ideogram:优秀的在线AI绘画平台
  • 【代码随想录day 15】 力扣 110.平衡二叉树
  • HTTP 请求返回状态码和具体含义?200、400、403、404、502、503、504等
  • 机械学习--SVM 算法
  • 用LaTeX优化FPGA开发:结合符号计算与Vivado工具链(二)
  • 华为网路设备学习-28(BGP协议 三)路由策略
  • Android Studio第一个kotlin项目“Hello Android”
  • kafak
  • windows自动获取wsl IP,并开启端口转发。
  • 【代码随想录day 14】 力扣 111.二叉树的最小深度
  • Axure基于中继器实现的组件库(导航菜单、动态表格)
  • Array Description(Dynamic programming)
  • 在发布应用程序内测时如何选择合适的分发上架方式?
  • Git 基础操作笔记(速查)
  • 视频遥测终端机是什么,其工作原理和应用领域
  • 高校合作 | 世冠科技联合普华、北邮项目入选教育部第二批工程案例
  • 01数据结构-图的概念和图的存储结构
  • 数据结构---二叉树(概念、特点、分类、特性、读取顺序、例题)、gdb调试指令、时间复杂度(概念、大O符号法、分类)
  • 【世纪龙科技】数智重构车身实训-汽车车身测量虚拟实训软件
  • 二叉树实现
  • Docker 创建镜像错误记录
  • Redis缓存击穿、穿透雪崩