diff --git a/NEWS.md b/NEWS.md
index 33178c92..8e331ed8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,6 @@
# RPostgres 1.1.1.9002
+- Windows: update libpq to 11.1.0
- Add user interrupt check while waiting for query results to be ready. Allows safe interruption of long-running queries (#193, @zozlak).
diff --git a/docs/news/index.html b/docs/news/index.html
index 6da8ab16..2dc657ca 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -108,6 +108,7 @@
+- Windows: update libpq to 11.1.0
- Add user interrupt check while waiting for query results to be ready. Allows safe interruption of long-running queries (#193, @zozlak).
diff --git a/src/Makevars.win b/src/Makevars.win
index f0151f7b..a794669d 100644
--- a/src/Makevars.win
+++ b/src/Makevars.win
@@ -1,7 +1,9 @@
-PKG_CPPFLAGS= -I../windows/libpq-9.5.2/include -DSTRICT_R_HEADERS
-PKG_LIBS= -L../windows/libpq-9.5.2/lib${R_ARCH} \
+VERSION = 11.1.0
+RWINLIB = ../windows/libpq-$(VERSION)
+PKG_CPPFLAGS = -I$(RWINLIB)/include -DSTRICT_R_HEADERS
+PKG_LIBS = -L$(RWINLIB)/lib${R_ARCH} \
-lpq -lssl -lcrypto -lwsock32 -lsecur32 -lws2_32 -lgdi32 -lcrypt32 -lwldap32
-CXX_STD=CXX11
+CXX_STD = CXX11
$(SHLIB):
@@ -11,4 +13,4 @@ clean:
rm -f $(SHLIB) $(OBJECTS)
winlibs:
- "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R"
+ "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION)
diff --git a/tools/winlibs.R b/tools/winlibs.R
index 7f29ebfb..802c7573 100644
--- a/tools/winlibs.R
+++ b/tools/winlibs.R
@@ -1,7 +1,8 @@
-# Build against static libpq
-if(!file.exists("../windows/libpq-9.5.2/include/libpq-fe.h")){
+# Link against libpq static libraries
+VERSION <- commandArgs(TRUE)
+if(!file.exists(sprintf("../windows/libpq-%s/include/libpq-fe.h", VERSION))){
if(getRversion() < "3.3.0") setInternet2()
- download.file("https://github.com/rwinlib/libpq/archive/v9.5.2.zip", "lib.zip", quiet = TRUE)
+ download.file(sprintf("https://github.com/rwinlib/libpq/archive/v%s.zip", VERSION), "lib.zip", quiet = TRUE)
dir.create("../windows", showWarnings = FALSE)
unzip("lib.zip", exdir = "../windows")
unlink("lib.zip")