Thread: Building proper static library libpq.a

Building proper static library libpq.a

From
Jeroen Ooms
Date:
I am working on bindings to libpq for the R programming language. For
windows I need to build libpq.a as a standalone static library (using
mingw-w64) that I can link into the client application. I have done
this for many other libraries (e.g. libmariadbclient) but I am having
difficulty generating a static library for libpq.

So the goal is to create a version of libpq.a that I can link to my
application together with libssl.a, libz.a, etc, and which does not
depend on external postgresql shared libraries:

  g++ -s -static-libgcc -o rpq.dll myapp.o -lpq -lssl -lcrypto -lgdi32
-lz -lws2_32

However by default the libpq.a gets built as a 99kb import library
that depends on libpq.dll (which depends on several other dll's...).
What I need is a static version of libpq.a (or perhaps multiple static
libraries) including the full implementation of libpq.

Based on some posts in the mailing list archives I tried using:

   --disable-shared --enable-static=libpq

However with no luck:

  configure: WARNING: unrecognized options: --disable-shared, --enable-static

Is there something I can pass to configure to create the full libpq
static library?