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.
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.5.x or 8.6.x. (Older versions might work, but are no longer tested.) On Ubuntu and similar systems, you need the tcl8.x and tcl8.x-dev packages.
PostgreSQL version 9.2.x or 9.3.x. (Older versions might work, but are no longer tested.) On Ubuntu and similar systems, you need the libpq5 and libpq-dev packages.
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. Starting with pgtcl-ng release 1.6.0, if the PostgreSQL command pg_config can be located with your command search PATH, you do not need specify the locations. For example, just this will work on many systems:
./configure
If pg_config is not on your PATH (or you are building a pgtcl-ng older than 1.6.0), you need to specify the location of the PostgreSQL library and include directories. For example:
./configure --with-postgres-include=/opt/postgresql/include \ --with-postgres-lib=/opt/postgresql/lib
The location of the Tcl installation also is needed. On many systems,
this is automatically located by configure.
If not, use --with-tcl=DIR
, where DIR is the path of
the directory containing tclConfig.sh
, and
--with-tclinclude=IDIR
, where IDIR is the path
of the directory containing Tcl header files. You might be able to
omit --with-tclinclude
if you have only one Tcl installation
and the header files are in a common place. (For some reason, configure
does not use the information in tclConfig.sh to locate the header files.)
For example, the following works on Ubuntu-14.04LTS (assuming the tcl8.5
and tcl8.5-dev packages are installed, as well as the PostgreSQL client
packages):
./configure --with-tcl=/usr/lib/tcl8.5
This may be needed if you have Tcl installed in an unusual place, or have multiple versions of Tcl installed:
./configure --with-tcl=/opt/tcl86/lib --with-tclinclude=/opt/tcl86/include
You can also use --libdir=DIR
to specify the
installation target directory if you want to use
make install
. You can omit --libdir
if you are going to manually install the library.
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. 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 libpgtcl2.1.1.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.6/pgtcl2.1
$
cp libpgtcl2.1.1.so pkgIndex.tcl /usr/lib/tcl8.6/pgtcl2.1
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.
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.