# Compiling psqlODBC on Windows

This page describes how to build the PostgreSQL ODBC Driver on Win32 platforms. Microsoft Visual C++ version 6.0 or Microsoft Visual C++ 2005 Edition. Other compilers may work but have not been formally tested. psqlODBC may be built either in the VC++ IDE or from the command line:

## IDE Method

A Microsoft Visual Studio project file (and workspace) is included in the source tree.

psqlodbc.dsp can be used with Microsoft Visual C++ 6.0.

psqlodbc.proj and psqlodbc.sln can be used with Microsoft Visual C++ 2005 Edition (including the Express edition which can be downloaded free of charge from http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx)

Preparation before the build:

1. The Windows distribution of PostgreSQL will install the required headers and libraries into C:\Program Files\PostgreSQL\8.2
2. OpenSSL should be installed into C:\OpenSSL (OpenSSL binaries can be downloaded from http://www.slproweb.com/products/Win32OpenSSL.html)

If you want to change the installation arrangement, it is necessary to edit the project settings.

Note:

The default build settings will create the following driver:

1. UNICODE support.
2. libpq.dll is used, therefore, SSL and Kerberos are supported.
3. ODBCVER is 0x0351.
4. The driver filename is "psqlodbc35w.dll".

## Command Line Method

Build method:

1. Use NMAKE.exe to build the dll for the 32bit environment.
   `C:\psqlodbc\> nmake /f win32.mak CFG=Release ALL`
   Possible configurations are Release and Debug.
   Possible build types are ALL or CLEAN.
2. Use NMAKE.exe to build the dll for the 64bit environment.
   `C:\psqlodbc\> nmake /f win64.mak CFG=Release ALL`
   Possible configurations are Release and Debug.
   Possible build types are ALL or CLEAN.

Note:

The following build options may be used:

Valiable | Values
CFG | Release(default), or Debug
PG_INC | $(PROGRAMFILES)\PostgreSQL\8.2\include
PG_LIB | $(PROGRAMFILES)\PostgreSQL\8.2\lib\ms
SSL_INC | C:\OpenSSL\include
SSL_LIB | C:\OpenSSL\lib\VC
LINKMT | MT
ANSI_VERSION | No (at the Yes, output dll name to psqlodbc30a.dll)
MSDTC | Yes (but VC++ 6.0 default is no)

1. UNICODE is default (psqlodbc35w.dll), unless ANSI_VERSION isselected (psqlodbc30a.dll)
2. libpq.dll is used, therefore, SSL and Kerberos are supported.
3. ODBCVER becomes 0x351 when UNICODE is selected, or becomes 0x0300 with ANSI_VERSION == Yes.
4. If MSDTC == Yes, "pgxalib.dll" is created.
5. In the MSDTC mode, ANSI_VERSION also creates "pgenlista.dll". or UNICODE creates "pgenlist.dll".

.