Debian Codegraph @

doc/html/libpgtcl-loading.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.6.0">
6 <title>Loading pgtcl into an Application</title>
7 <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.79">
8 <link rev="MADE" href="mailto:[email protected]">
9 <link rel="HOME" title="PostgreSQL Tcl Interface Documentation" href="index.html">
10 <link rel="UP" title="pgtcl - Tcl Binding Library" href="libpgtcl.html">
11 <link rel="PREVIOUS" title="pgtcl - Tcl Binding Library" href="libpgtcl.html">
12 <link rel="NEXT" title="pgtcl Command Reference" href="libpgtcl-ref.html">
13 <link rel="STYLESHEET" type="text/css" href="stylesheet.css">
14 </head>
15 <body class="SECT1">
16 <div class="NAVHEADER">
17 <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
18 <tr>
19 <th colspan="5" align="center" valign="bottom">PostgreSQL Tcl Interface Documentation</th>
20 </tr>
21 <tr>
22 <td width="10%" align="left" valign="top"><a href="libpgtcl.html" accesskey="P">Prev</a></td>
23 <td width="10%" align="left" valign="top"><a href="libpgtcl.html">Fast Backward</a></td>
24 <td width="60%" align="center" valign="bottom">Chapter 1. <span class="APPLICATION">pgtcl</span> - Tcl Binding Library</td>
25 <td width="10%" align="right" valign="top"><a href="libpgtcl.html">Fast Forward</a></td>
26 <td width="10%" align="right" valign="top"><a href="libpgtcl-ref.html" accesskey="N">Next</a></td>
27 </tr>
28 </table>
29 <hr align="left" width="100%"></div>
30 <div class="SECT1">
31 <h1 class="SECT1"><a name="LIBPGTCL-LOADING" id="LIBPGTCL-LOADING">1.2. Loading <span class="APPLICATION">pgtcl</span> into an Application</a></h1>
32 <p>Before using <span class="APPLICATION">pgtcl</span> commands, you must load the <tt class="FILENAME">libpgtcl</tt> library into your Tcl application. This is normally done with the <tt class="LITERAL">package require</tt> command. Here is an example:</p>
33 <pre class="PROGRAMLISTING">package require Pgtcl 1.5</pre>
34 <p><tt class="LITERAL">package require</tt> loads the <tt class="LITERAL">libpgtcl</tt> shared library, and loads any additional Tcl code that is part of the <tt class="LITERAL">Pgtcl</tt> package. Note that you can manually generate the pkgIndex.tcl file, or use <tt class="COMMAND">make pkgIndex.tcl</tt> or <tt class="COMMAND">make pkgIndex.tcl-hand</tt> to have make generate it.</p>
35 <p>The old way to load the shared library is by using the Tcl <tt class="LITERAL">load</tt> command. Here is an example:</p>
36 <pre class="PROGRAMLISTING">load libpgtcl[info sharedlibextension]</pre>
37 <p>Although this way of loading the shared library is deprecated, we continue to document it for the time being, because it may help in debugging if, for some reason, <tt class="LITERAL">package require</tt> is failing. The use of <tt class="LITERAL">info sharedlibextension</tt> is recommended in preference to hard-wiring <tt class="LITERAL">.so</tt> or <tt class="LITERAL">.sl</tt> or <tt class="LITERAL">.dll</tt> into the program.</p>
38 <p>The <tt class="LITERAL">load</tt> command will fail unless the system's dynamic loader knows where to look for the <tt class="FILENAME">libpgtcl</tt> shared library file. You may need to work with <tt class="COMMAND">ldconfig</tt>, or set the environment variable <tt class="ENVAR">LD_LIBRARY_PATH</tt>, or use some equivalent facility for your platform to make it work. Refer to the <span class="PRODUCTNAME">PostgreSQL</span> installation instructions for more information.</p>
39 <p><tt class="FILENAME">libpgtcl</tt> in turn depends on the interface library <tt class="FILENAME">libpq</tt>, so the dynamic loader must also be able to find the <tt class="FILENAME">libpq</tt> shared library. In practice this is seldom an issue, since both of these shared libraries are normally stored in the same directory, but it can be a stumbling block in some configurations.</p>
40 <p>If you use a custom executable for your application, you might choose to statically bind <tt class="FILENAME">libpgtcl</tt> into the executable and thereby avoid the <tt class="LITERAL">load</tt> command and the potential problems of dynamic linking. See the source code for <span class="APPLICATION">pgtclsh</span> for an example.</p>
41 <p>If you want to use the <code class="FUNCTION">pg_sqlite</code> bridge, you must still explicitly <tt class="LITERAL">"package require sqlite3"</tt> before executing any <tt class="LITERAL">sqlite3</tt> commands.</p>
42 </div>
43 <div class="NAVFOOTER">
44 <hr align="left" width="100%">
45 <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
46 <tr>
47 <td width="33%" align="left" valign="top"><a href="libpgtcl.html" accesskey="P">Prev</a></td>
48 <td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td>
49 <td width="33%" align="right" valign="top"><a href="libpgtcl-ref.html" accesskey="N">Next</a></td>
50 </tr>
51 <tr>
52 <td width="33%" align="left" valign="top"><span class="APPLICATION">pgtcl</span> - Tcl Binding Library</td>
53 <td width="34%" align="center" valign="top"><a href="libpgtcl.html" accesskey="U">Up</a></td>
54 <td width="33%" align="right" valign="top"><span class="APPLICATION">pgtcl</span> Command Reference</td>
55 </tr>
56 </table>
57 </div>
58 </body>
59 </html>