From 363d4e1f5a3896d773bfe76ac7e4d9f2e486898d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20ldev?= Date: Mon, 1 Jan 2024 18:22:15 -0300 Subject: [PATCH] db.pg: fix compilation error with the msvc compiler on windows, and add readme (#20326) --- vlib/db/pg/README.md | 5 +++++ vlib/db/pg/pg.c.v | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/vlib/db/pg/README.md b/vlib/db/pg/README.md index ec15a9f199..d9349d94e3 100644 --- a/vlib/db/pg/README.md +++ b/vlib/db/pg/README.md @@ -69,6 +69,11 @@ format *PG_VERSION_NUM 17* without 0 also should work 7. Add libpq.dll to v/thirdparty/pg/win64 +If you are going to use the msvc compiler: +7. Add libpq.lib(C:\Program Files\PostgreSQL\{version}\lib) to v/thirdparty/pg/win64/msvc + +8. Add libpq.dll, libcrypto-3-x64.dll, libssl-3-x64.dll to where your executable is. + To get the libpq.dll file, you can install the PostgreSQL database, and get this dll from its bin/ folder, or compile DB from source code. ``` diff --git a/vlib/db/pg/pg.c.v b/vlib/db/pg/pg.c.v index 049a36b967..eb64d05f26 100644 --- a/vlib/db/pg/pg.c.v +++ b/vlib/db/pg/pg.c.v @@ -6,7 +6,11 @@ import orm $if $pkgconfig('libpq') { #pkgconfig --cflags --libs libpq } $else { - #flag -lpq + $if msvc { + #flag -llibpq + } $else { + #flag -lpq + } #flag linux -I/usr/include/postgresql #flag darwin -I/opt/local/include/postgresql11