Abstract
This section describes how to build and install pgtcl 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, read the following sections.
Here are the prerequisites for building pgtcl 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 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 that you really only need the directories
src/interfaces/libpq,
src/backend,
src/include, and
src/port.
You can probably build this with Microsoft's C compiler, but we don't have one and don't know how to do it.
Following the instructions below, you will first build the the PostgreSQL
libpq loadable library. Then you will build the
pgtcl 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.)
Here are the steps to build pgtcl 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 is unpacked at
c:\src\pgtcl.
Adjust the pathnames shown below to match your actual installation.
Create a Borland import library from the ActiveState Tcl link library.
C:\>cd c:\apps\tcl\libC:\>coff2omf tcl84.lib tcl84omf.lib
Build the libpq loadable library,
blibpq.dll.
In c:\src\pgsql\src\include, copy the file
pg_config.h.win32 to pg_config.h,
overwriting the existing file.
(This would be done by the Makefile, but only if
pg_config.h is missing, and we may need to edit the file.)
If you are running PostgreSQL 7.4.1, there is
one source patch you need to apply. (This patch is already present in 7.4.2
and higher.)
In the source directory c:\src\pgsql\src\port
edit the file thread.c and change the line:
#if defined(WIN32) && defined(_MSC_VER)
to:
#if defined(WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__))
If you are running PostgreSQL 8.1.4 (and possibly other 8.1.x versions), check for and apply the following changes if needed.
In c:\src\pgsql\src\include, edit the file
pg_config.h (which you just copied above from
pg_config.h.win32). In the block that is conditional
on the Borland compiler, add an empty definition of
inline so the file looks like this:
#ifdef __BORLANDC__
#define inline
...
In the directory c:\src\pgsql\src\interfaces\libpq,
edit the file bcc32.mak to change the creation of the
pg_config_paths.h file so the line looks like this:
pg_config_paths.h: bcc32.mak
echo \#define SYSCONFDIR "" > pg_config_paths.h
Leave the bcc32.mak Makefile open for the next step.
In the directory c:\src\pgsql\src\interfaces\libpq,
edit the file bcc32.mak as follows:
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.)
Change LINK32_FLAGS to add the option
-c to the end. This is needed to make the linker
case-sensitive, because libpq has
external symbols which differ only in case.
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.
Build the libpq library:
C:\>cd c:\src\pgsql\src\interfaces\libpqC:\>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.
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:
Define BORLAND to point to the top of your Borland
installation directory.
Define TCL to point to the top of your Tcl installation
directory.
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.