MacOS X, Postgresql and Aqua Tcl/Tk - Mailing list pgsql-general

From Jerry LeVan
Subject MacOS X, Postgresql and Aqua Tcl/Tk
Date
Msg-id C9935621-88E4-11D8-B263-000393779D9C@eku.edu
Whole thread Raw
List pgsql-general
Here is how I spent the last couple of days...

Using aqua tcl/tk with postgresql seems to take a bit
of extra work.

With clues from Dan Steffen, I think I have it working...

Here is the contents of my postgresql config command:

./configure --bindir=/usr/local/bin --mandir=/usr/local/share/man  \
   --enable-recode --with-CXX --enable-odbc  --enable-syslog \
   --enable-unicode-conversion --enable-multibyte --with-perl --with-tcl
\
   --with-tk  --with-openssl --with-java \
   --with-tclconfig=/Library/Frameworks/Tcl.framework \
   --with-tkconfig=/Library/Frameworks/Tk.framework

Starting pgtksh opens the pgtksh window but clicking on the
rascal gives and error message:

     set front process failed, -606

The maintainer of the Aqua tcl/tk suggested that I review the
mac-tcl list, and indeed the answer was sorta located therein.

The problem is evidently that OS X does not believe that pgtksh
is a mac application.

A solution is to create a mac application like directory structure.
Here is what I did:
   In /usr/local/bin I created a directory hierarchy

     pgtksh.app/Contents/MacOS

   and in the MacOS directory I placed the pgtksh executable.

   Then in /usr/local/bin I created a file "pgtksh" the contents
   of this file :
   #!/bin/sh
   "/usr/local/bin/pgtksh.app/Contents/MacOS/pgtksh" "$@"

   I can then invoke pgtksh by name, the script runs and the
   executable is properly started.
   This approach more or less mirrors what the Aqua Tk wish
   application does.

   I thought it would be nice not to have to rely on pgtksh
   and simply "load" the libpgtcl dynamically into either
   wish or tclsh. Regretably there are problems...

   The make file that builds libpgtcl uses the "-bundle" directive
   in the link step, this builds a Mach O bundle resource which
   is not recognized by the "load" command in tcl/wish.

   I edited Makefile.shlib and in the darwin part replaced "-bundle"
   by "-dynamiclib".
   Then in the libpgtcl directory I did a make clean and then make.
   This gives a loadable libpgtcl.so file! The desired suffix for
   such files is ".dylib". I went back and edited the Makefile.shlib
   and arranged that the suffix be ".dylib" and rebuilt the
   libpgtcl shared lib. The build produced a libpgtcl.dylib.

   When I tried loading libpgtcl.dylib into tclsh I got an error
   to effect that libpq.dylib could not be found. I then went
   back and built a sharable libpq.dylib and tried again. This
   time "loading" libpqtcl.dylib caused a complaint that two entry
   points could not be found.

   I then tryed building the whole thing with -dynamiclib instead of
   -bundle, but soon found out that some components use the bundle
   loader.

   Finally I rebuilt everything from scratch without using the
   -dynamiclib switch and rebuilt by hand the libpgtcl.so file
   using the -dynamiclib switch and manually copied the library
   to /usr/local/pgsql/lib.

   It appears that I can now "load" libpgtcl.so into wish/tclsh
   ( but I have to specify the full path).

   [time passes...]
   I did not like the idea of using the full path to load the
   postgresql library into tclsh/wish.

   After a bit of experimenting I finally did the following
   I noticed that the addon packages were stored in /Library/Tcl.
   I created a directory libpgtcl2.4 in this directory. I copied
   /usr/local/pgsql/lib/libpgtcl.so.2.4 into libpgtcl2.4 and
   renamed it to libpgtcl.dylib. I then ran the following command
   from tclsh:

      pkg_mkIndex /Library/Tcl/libpgtcl2.4

   this create a file pkgIndex.tcl in the target directory.
   the contents of this file is:
    # Tcl package index file, version 1.1
    # This file is generated by the "pkg_mkIndex" command
    # and sourced either when an application starts up or
    # by a "package unknown" script.  It invokes the
    # "package ifneeded" command to set up package-related
    # information so that packages will be loaded automatically
    # in response to "package require" commands.  When this
    # script is sourced, the variable $dir must contain the
    # full path name of this file's directory.

    package ifneeded Pgtcl 1.4 [list load [file join $dir libpgtcl.dylib]]

  I was a bit surprised by the appearance of "Pgtcl". However I
  can now load the postgresql library by the command:

    package require Pgtcl




pgsql-general by date:

Previous
From: Ciprian Popovici
Date:
Subject: Are functions automatically transactioned?
Next
From: Gregory Wood
Date:
Subject: Re: Can we have time based triggers in Postgresql??