2.2. Building and Installing on Windows Systems (Borland Compiler)

Abstract

This section describes how to build and install pgtcl-ng on Windows systems. Building on Windows systems is less automated than on Unix-like systems, and you are advised to fetch a binary release instead of building it yourself. If you get a binary release, follow the instructions in the release to install it. Installation generally just involves copying two DLL files. If you want to compile your own pgtcl-ng, read the following sections.

2.2.1. Prerequisites for Windows Systems

Here are the prerequisites for building pgtcl-ng on Windows. Note that specific versions of each product are mentioned. Newer versions will probably work, and older versions are less likely to work. The versions listed here have been tested.

To build pgtcl-ng on Windows, you need:

  • ActiveState ActiveTcl Tcl/Tk version 8.4.5, installed with libraries and header files;

  • Borland C++ Builder Command Line Tools (BCC32 5.5.1), installed and configured;

  • PostgreSQL 7.4.1 source release or higher, unpacked. You cannot use any release before 7.4.1.

Note

You can probably build this with Microsoft's C compiler, but we don't have one and don't know how to do it.

2.2.2. Building and Installing - Windows Systems

Following the instructions below, you will first build the the PostgreSQL libpq loadable library. Then you will build the pgtcl-ng loadable library libpgtcl, and link it with ActiveState Tcl libraries. (Even though ActiveState libraries are built with Microsoft C, they can be linked with Borland C programs, with one extra step. However, you cannot use the Tcl stubs interface.)

Note

For some versions of PostgreSQL, changes or patches need to be applied to the source in order to build libpq using the Borland compiler. Changes or patches for tested releases can be found in the pgtcl-ng source release (1.6.0 or higher) in the patches/ subdirectory. Refer to the README file in that directory, and apply the relevant changes, before continuing with the instructions in this document.

Here are the steps to build pgtcl-ng on Windows. You will be working mostly in a Command Prompt window. (The prompt is shown below as C:\> but your prompt will vary.)

The steps below assume your Borland compiler is installed at c:\apps\bcc, ActiveState Tcl is installed at c:\apps\tcl, your PostgreSQL source is unpacked at c:\src\pgsql, and pgtcl-ng is unpacked at c:\src\pgtcl. Adjust the pathnames shown below to match your actual installation.

  1. Create a Borland import library from the ActiveState Tcl link library.

    C:\> cd c:\apps\tcl\lib
    C:\> coff2omf tcl84.lib tcl84omf.lib
    
  2. Build the libpq loadable library, blibpq.dll.

    1. In c:\src\pgsql\src\include, copy the file pg_config.h.win32 to pg_config.h, overwriting the existing file, as shown.

      C:\>  cd c:\src\pgsql\src\include
      C:\>  copy pg_config.h.win32 pg_config.h
      
    2. If you are running PostgreSQL 8.2.0 or higher, you need a pg_config_os.h file in the include directory. Copy this from the file port\win32.h as shown.

      C:\>  cd c:\src\pgsql\src\include
      C:\>  copy port\win32.h pg_config_os.h
      
    3. In the directory c:\src\pgsql\src\interfaces\libpq, edit the file bcc32.mak as follows:

      1. Uncomment the line and define BCB to point to your Borland installation directory. (Although this isn't needed to compile programs with a proper PATH, it is needed for the resource compiler BRC32.)

      2. Change the link command run-time library from cw32mti.lib to the static version cw32mt.lib. This is necessary or applications using fprintf will crash.

    4. Build the libpq library:

      C:\>  cd c:\src\pgsql\src\interfaces\libpq
      C:\>  make -N -f bcc32.mak
      

      This will create the loadable library file blibpq.dll, and an import library blibpqdll.lib, in the src\interfaces\libpq\Release directory. You need these for the next step.

  3. Build the pgtcl loadable library, libpgtcl.dll. Change directory to the unpacked pgtcl source distribution. For example:

    C:\>  cd c:\src\pgtcl
    

    Edit the file bcc32.mak as follows:

    1. Define BORLAND to point to the top of your Borland installation directory.

    2. Define TCL to point to the top of your Tcl installation directory.

    3. Define POSTGRESQL to point to the top-level source directory src inside your unpacked PostgreSQL distribution, where you have already built libpq. For example: POSTGRESQL=C:\src\pgsql\src

    Now build libpgtcl:

    C:\>  make -f bcc32.mak
    

    This will create the file libpgtcl.dll.

To use pgtcl on Windows, you will need the two files you built: c:\src\pgsql\src\interfaces\libpq\release\blibpq.dll, and c:\src\pgtcl\libpgtcl.dll Refer to Chapter 3, Loading pgtcl into an Application for information about using these from your application. The Makefile contains an installation target you may choose to use:

C:\>  make -f bcc32.mak install

This will install the two library files and a specially modified package loading script into a new package directory in your Tcl library directory. See Section 3.1, “Using the Tcl Package Command” for more information.