I had found undefined symbols in interfaces/libpgtcl/libpgtcl.so when
trying to use pgaccess on a NetBSD box.  It turns out the problem is
with not including symbols from interfaces/libpq/libpq.so, but this
apparently only occurs with BSD ports (my guess; Marc can you verify
this under FreeBSD?).  In the libpgtcl Makefile are the following
relevant fragments:

ifeq ($(PORTNAME), bsd)
  ifdef BSD_SHLIB
    install-shlib-dep	:= install-shlib
    shlib		:= libpgtcl.so.1.0
    LDFLAGS_SL		= -x -Bshareable -Bforcearchive
    CFLAGS		+= $(CFLAGS_SL)
  endif
endif

$(shlib): $(OBJS)
	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS)
	ln -sf $@ libpgtcl.so

In the same Makefile all other ports include reference to libpq in the
LDFLAGS_SL variable.  If this same reference is included for the BSD
ports, the loader complains because the symbols precede the libpgtcl
objects.  If, however, the reference to libpq follows the libpgtcl
objects (see patch below), all is well.  

It seems logical that the libpq reference should follow the libpgtcl
objects for all ports, but the following patch retains the old
behavior for all ports except BSD ones (tested only for NetBSD v1.3
and pgaccess v0.81).  If it really works for other ports, I suggest
removing the libpq references from any LDFLAGS_SL variable and adding
them to the ld command (i.e., replace BSD_LIBPQ with LIBPQ).

Please try this with other BSD ports to see if this solutions works
for ones besides NetBSD.

Cheers,
Brook

===========================================================================
--- src/interfaces/libpgtcl/Makefile.in.orig	Fri Feb 13 01:01:00 1998
+++ src/interfaces/libpgtcl/Makefile.in	Sun Mar  1 23:06:24 1998
@@ -32,12 +32,14 @@
 install-shlib-dep :=
 shlib             := 
 
+LIBPQ			= -L $(SRCDIR)/interfaces/libpq -lpq
+
 ifeq ($(PORTNAME), linux)
   ifdef LINUX_ELF
     install-shlib-dep	:= install-shlib
     shlib		:= libpgtcl.so.1
     CFLAGS		+= $(CFLAGS_SL)
-    LDFLAGS_SL		= -shared -L $(SRCDIR)/interfaces/libpq -lpq
+    LDFLAGS_SL		= -shared $(LIBPQ)
   endif
 endif
 
@@ -47,20 +49,21 @@
     shlib		:= libpgtcl.so.1.0
     LDFLAGS_SL		= -x -Bshareable -Bforcearchive
     CFLAGS		+= $(CFLAGS_SL)
+    BSD_LIBPQ		= $(LIBPQ)
   endif
 endif
 
 ifeq ($(PORTNAME), i386_solaris)
   install-shlib-dep	:= install-shlib
   shlib			:= libpgtcl.so.1
-  LDFLAGS_SL		= -G -z text -L $(SRCDIR)/interfaces/libpq -lpq
+  LDFLAGS_SL		= -G -z text $(LIBPQ)
   CFLAGS		+= $(CFLAGS_SL)
 endif
 
 ifeq ($(PORTNAME), univel)
   install-shlib-dep	:= install-shlib
   shlib			:= libpgtcl.so.1
-  LDFLAGS_SL		= -G -z text -L $(SRCDIR)/interfaces/libpq -lpq
+  LDFLAGS_SL		= -G -z text $(LIBPQ)
   CFLAGS		+= $(CFLAGS_SL)
 endif
 
@@ -78,7 +81,7 @@
 	$(RANLIB) libpgtcl.a
 
 $(shlib): $(OBJS)
-	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) 
+	$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(BSD_LIBPQ)
 	ln -sf $@ libpgtcl.so
 
 .PHONY: beforeinstall-headers install-headers



Sun, 1 Mar 1998 23:17:44 -0700 (MST)
Brook Milligan <brook@trillium.NMSU.Edu>
SOLUTION: undefined symbols in libpgtcl.so