如何解决vcpkg编译postgresql报错问题

vcpkg编译libpq库时报错,查看日志文件C:\vcpkg\buildtrees\libpq\build-libpq-x64-windows-dbg-err.log,内容显示

1
Unable to determine Visual Studio version: The nmake version could not be determined. at C:/vcpkg/buildtrees/libpq/x64-windows-dbg/src/tools/msvc/Mkvcbuild.pm line 97.

相关内容是

1
2
3
4
5
6
7
8
9
our $config = shift;

chdir('../../..') if (-d '../msvc' && -d '../../../src');
die 'Must run from root or msvc directory'
unless (-d 'src/tools/msvc' && -d 'src');

my $vsVersion = DetermineVisualStudioVersion();

$solution = CreateSolution($vsVersion, $config);

DetermineVisualStudioVersion()函数用于检测系统中安装的Visual Studio版本,但是没有检测到,所以报错。

最简单的办法就是写死版本

1
my $vsVersion = '17.00';

使用命令编译

1
vcpkg install --editable libpq

如何解决vcpkg编译postgresql报错问题
https://blog.jackeylea.com/vcpkg/how-to-build-postgresql-with-vcpkg/
作者
JackeyLea
发布于
2025年6月30日
许可协议