This section describes how to build and install pgtcl-ng on Windows systems using Borland tools. 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 DLL file(s). If you want to compile your own pgtcl-ng, read the following sections.
Starting with pgtclng-1.8.0, only the MinGW toolset is being used to build pgtcl-ng for Windows. Building with the Borland compiler is no longer being tested. Refer to Section 2.2, “Building and Installing on Windows (MinGW tools)” for more information.
The PostgreSQL-9.0.x libpq does not compile with the Borland compiler, and no patches are currently available.
Here are the prerequisites for building pgtcl-ng on Windows using Borland tools. 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 with Borland tools, you need:
ActiveState ActiveTcl Tcl/Tk version 8.5.8, installed with libraries and header files.
Tcl 8.5.x source release or higher, unpacked. This is only needed if you are building a stubs-enabled version of Pgtcl-ng, which will work with multiple versions of Tcl. If you do not need or want a stubs-enabled Pgtcl-ng, you will not need the Tcl source code.
Borland C++ Builder Command Line Tools (BCC32 5.5.1), installed and configured.
PostgreSQL 8.4.x source release, unpacked. (Pgtcl-ng was previously built with PostgreSQL releases going back to 7.4.1, and it may still be possible to do so. But note that if you build with the latest PostgreSQL release, you will be able to use the result to connect to older versions of PostreSQL databases.)
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.
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
,
pgtcl-ng is unpacked at
c:\src\pgtcl
,
and the Tcl source release (if needed) is unpacked at
c:\src\tcl
.
Adjust the pathnames shown below to match your actual installation.
If you are building with Tcl stubs, you will need to compile one module from the Tcl source in order to get a Borland-built stubs library. Follow item (A) below. If you are not building with Tcl stubs, you need a Borland import library for Tcl. Follow item (B) below.
Follow this step if you are building with Tcl stubs. You need a version of
the Tcl stubs library (tclstub85.lib
for Tcl 8.5.x)
that was built with Borland C in order to link to Pgtcl-ng. (This is because
the coff2omf converter used in the alternate step
below does not work on the tclstub85.lib library supplied with ActiveTcl.)
In the Tcl source directory c:\src\tcl\win
, edit the
file makefile.bc
and change the symbol TOOLS32 to
point to your Borland directory, for example
TOOLS32=c:\apps\bcc. Now build the stubs library:
C:\>
cd c:\src\tcl\win
C:\>
mkdir ..\Release
C:\>
make -f makefile.bc ..\Release\tclstub85.lib
The resulting file ..\Release\tclstub85.lib
should be
renamed so it does not conflict with the Active-Tcl stubs library, and
copied into the Tcl library directory:
C:\>
copy ..\Release\tclstub85.lib c:\apps\tcl\lib\tclstub85bcc.lib
Follow this step instead of the previous step if you are not building with
Tcl stubs.
Create a Borland import library from the ActiveState Tcl link library,
which is called tcl84.lib
for Tcl-8.4.x and
tcl85.lib
for Tcl-8.5.x. Use the appropriate
filenames.
C:\>
cd c:\apps\tcl\lib
C:\>
coff2omf tcl85.lib tcl85omf.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, as shown.
C:\>
cd c:\src\pgsql\src\include
C:\>
copy pg_config.h.win32 pg_config.h
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
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.)
Check the link command run-time library. Search the file for
cw32mt
and check the library name. If it is
cw32mti.lib
, change it to the static version
cw32mt.lib
. This is necessary or applications
using fprintf
will crash. PostgreSQL-8.2.4 and
higher already seem to have this change.
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.
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
Check the TCLLIB definition in the Makefile and the associated comments.
If you are building with Tcl stubs, use the Tcl stub library you built above
(for example, tclstub85bcc.lib
)
and leave the USE_TCL_STUBS definition as is.
If you are not building with Tcl stubs, use the OMF import library you
build above instead (for example, tcl85omf.lib
)
and comment out the USE_TCL_STUBS symbol.
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.
This version of the manual was produced for the
Pgtcl-ng Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
Pgtcl-ng project
downloads area.