Abstract
This chapter describes how to build and install
pgtcl-ng, making it available for use
in your applications.
You should check the release for README
or
INSTALL
files,
which may contain more up-to-date information.
This chapter only applies to the pgtcl-ng implementation of pgtcl. For other implementations, check the included documentation.
Abstract
This section describes how to build and install pgtcl-ng on Unix-like systems, including Linux.
To build pgtcl-ng on Unix-like Systems, you need:
Tcl/Tk version 8.3.1 or higher, with 8.4.4 or higher strongly recommended.
PostgreSQL version 7.4 or higher, with 8.1.4 or higher recommended.
The usual building tools such as C compiler, make, and a shell.
Pgtcl-ng is Tcl Extension Architecture (TEA)
compliant, shipping with a standard configure
script. You do not need to have a PostgreSQL
source distribution available to build pgtcl-ng,
but you need a PostgreSQL installation
with libraries and header files.
After unpacking the pgtcl-ng distribution, change directory into the top level of the distribution.
To configure pgtcl-ng, the paths to the
to the PostgreSQL include files and library files must be known.
For releases of pgtcl-ng before 1.6.0, you
must specify these paths on the configure
command line.
If you have the pg_config program supplied with
PostgreSQL on your PATH
,
you can use it to specify the directories as follows:
$
./configure --prefix=/usr/local \ --libdir=/usr/lib/tcl8.4 \ --with-postgres-include=$(pg_config --includedir) \ --with-postgres-lib=$(pg_config --libdir)
If you don't have pg_config available, you can specify the directories on the command line, for example:
$
./configure --prefix=/usr/local \ --libdir=/usr/lib/tcl8.4 \ --with-postgres-include=/opt/postgres/include \ --with-postgres-lib=/opt/postgres/lib
assuming you have installed PostgreSQL
in the directory /opt/postgres
.
In the above configure commands, we have specified both
--prefix
and --libdir
.
If you are going to manually install the product (which is easy, since
there is just one file produced), you can use anything you want or omit these.
If you plan to use the install
target in the
Makefile, you need to point --libdir
to a
location where Tcl will look for package directories. On a typical
system, this may be /usr/lib/tcl8.4/
as shown above.
The --prefix
is only used for the header file
installation (which is normally not needed anyway).
Starting with pgtcl-ng release 1.6.0,
you can omit the --with-postgres-lib
and/or
--with-postgres-include
options to configure,
and the pg_config command will be used
to locate those directories.
For this to work, pg_config needs to be
on your PATH.
pg_config is part of the PostgreSQL installation.
You may use configure like this:
$
./configure --prefix=/usr/local \ --libdir=/usr/lib/tcl8.4
pg_config expands symbolic links in pathnames.
This is not significant for the include directory, but it can be for the
library directory, because it becomes part of the built library
(as rpath
), used to locate the PostgreSQL library
libpq at runtime.
If you prefer to reference your PostgreSQL library path through a symbolic
link (for example, so you can use the libraries and executables
on a system with the same symbolic link but a different physical path),
then do not allow configure to use
pg_config.
Specify --with-postgres-lib
when configuring instead.
To build pgtcl-ng, just type:
$
make
If all goes well, you will end up with a shared library file
named something like libpgtcl1.6.0.so
.
You can install pgtcl-ng with:
$
make install
to install everything in the paths set during configure, as indicated above. If the paths are chosen right, the result will be enabled for package loading, as described in Section 3.1, “Using the Tcl Package Command”.
You may choose instead to manually install pgtcl-ng.
Refer to Chapter 3, Loading pgtcl into an Application for methods of using
pgtcl-ng with your application.
If you will be loading libpgtcl
directly
in your application, you need only copy that file into a convenient
location for loading. Note that libpgtcl
will
need to find the PostgreSQL libpq
loadable library.
If you want to be able to load libpgtcl into applications using
package require Pgtcl
you need to install libpgtcl
into a subdirectory
of Tcl's tcl_pkgPath
or auto_path
,
and include the file pkgIndex.tcl
which tells Tcl
how to load the package. For example:
$
mkdir /usr/lib/tcl8.4/pgtcl1.6
$
cp libpgtcl1.6.0.so pkgIndex.tcl /usr/lib/tcl8.4/pgtcl1.6
This is what the make install
target does.
Note: The name of the directory under the Tcl library directory is not
important, as the extension will be found regardless of the directory name.
You may choose to use the three-part version number in the name, or just
the major and minor version numbers.