24th September 2020: PostgreSQL 13 Released!
Supported Versions: 9.6 / 9.5
Unsupported versions: 9.4 / 9.3 / 9.2 / 9.1 / 9.0

16.2. Building libpq with Visual C++ or Borland C++

Using Visual C++ 7.1-9.0 or Borland C++ to build libpq is only recommended if you need a version with different debug/release flags, or if you need a static library to link into an application. For normal use the MinGW or Visual Studio or Windows SDK method is recommended.

To build the libpq client library using Visual Studio 7.1 or later, change into the src directory and type the command:

nmake /f win32.mak

To build a 64-bit version of the libpq client library using Visual Studio 8.0 or later, change into the src directory and type in the command:

nmake /f win32.mak CPU=AMD64

See the win32.mak file for further details about supported variables.

To build the libpq client library using Borland C++, change into the src directory and type the command:

make -N -DCFG=Release /f bcc32.mak

16.2.1. Generated Files

The following files will be built:


The dynamically linkable frontend library


Import library to link your programs to libpq.dll


Static version of the frontend library

Normally you do not need to install any of the client files. You should place the libpq.dll file in the same directory as your applications executable file. Do not install libpq.dll into your Windows, System or System32 directory unless absolutely necessary. If this file is installed using a setup program, then it should be installed with version checking using the VERSIONINFO resource included in the file, to ensure that a newer version of the library is not overwritten.

If you are planning to do development using libpq on this machine, you will have to add the src\include and src\interfaces\libpq subdirectories of the source tree to the include path in your compiler's settings.

To use the library, you must add the libpqdll.lib file to your project. (In Visual C++, just right-click on the project and choose to add it.)

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.