Subject: Re: HELP: Creating TCL loadable modules in HP / tclLoadShl.c patch - DN [1]


Jochen Loewer <jochen_loewer@bbn.hp.com> - 06 May 1999 - comp.lang.tcl

 To get the names of the 'unresolved symbols' printed under HPUX 10.20 at
 load time of the shared library you can apply following patch (the
 flag BIND_VERBOSE is added).
 Why is this not standard? May be, because it writes perhaps to stderr?
 At least this helps a lot while within development process.

 *** tcl8.0.5/unix/tclLoadShl.c-orig    Thu Apr  1 15:30:14 1999
 --- tcl8.0.5/unix/tclLoadShl.c    Thu Apr  1 15:30:42 1999
 ***************
 *** 60,66 ****
       shl_t handle;
       Tcl_DString newName;

 !     handle = shl_load(fileName, BIND_IMMEDIATE, 0L);
       if (handle == NULL) {
       Tcl_AppendResult(interp, "couldn't load file \"", fileName,
           "\": ", Tcl_PosixError(interp), (char *) NULL);
 --- 60,66 ----
       shl_t handle;
       Tcl_DString newName;

 !     handle = shl_load(fileName, BIND_IMMEDIATE|BIND_VERBOSE, 0L);
       if (handle == NULL) {
       Tcl_AppendResult(interp, "couldn't load file \"", fileName,
           "\": ", Tcl_PosixError(interp), (char *) NULL);

 Jochen.

 cracker31 wrote:
 >
 >     I have recently started playing around with creating loadable
 > modules.  I started out in Windows and had no problems.  I then tried
 > doing the same thing on HP 10.20 using the same code that I used for
 > windows.  Of course I removed any code that was specific to windows.
 >     Even though I can create the shared library, I am unable to load
 > it.  I keep getting "unresolved symbol".  If I do an "nm -u test.sl" on
 > my library it returns "Tcl_CreateCommand" as an undefied symbol.  This
 > is OK I think because it should pick up this symbol from libtcl.sl at
 > run time.  I double checked to make sure my SHLIB_PATH was setup
 > correctly.
 >
 >     The version of TCL I am using is tcl8.0.x.  Below is the makefile I
 > am using and an example of my code.
 >
 >     Any idea whats wrong?
 >
 > ##### CODE ######
 >
 > #include <tcl.h>
 >
 >  int Test_sample_Cmd(
 >         ClientData clientData,
 >         Tcl_Interp *interp,
 >         int argc,
 >         char *argv[])
 > {
 >                 return TCL_OK;
 > }
 >
 > int Tetfile_Init(
 > Tcl_Interp *interp)
 > {
 >
 >         Tcl_CreateCommand(interp, "test_sample", Test_sample_Cmd,
 > (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
 >         return TCL_OK;
 > }
 >
 > ##### MAKEFILE ######
 >
 > # compiler-related
 >
 >       CXX = /opt/aCC/bin/aCC
 >   CXXOPTS = -v -Wl,-v -O +z +DAportable
 >   CXXINCS = -I$(HOME)/tcl/include -I$(SRCDIR)
 >   CXXDEFS = -D__HPUX__ -D_TCL80 -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1
 > -Dunix
 >
 >  CXXFLAGS = $(CXXOPTS) $(CXXINCS) $(CXXDEFS)
 >
 > # linker-related
 >
 >        LD = /usr/bin/CC
 >   LDFLAGS = -b -L$(HOME)/tcl/lib -v -Wl,-v -Wl,+vallcompatwarnings
 > LOADLIBES = -lstd -ldld -lC -lCsup -lm -ltcl8.0
 >
 > # general
 >
 >   OBJ_EXT = o
 >    SO_EXT = sl
 >        RM = /usr/bin/rm -f
 >
 > # main
 >
 > BASEDIR = ${HOME}/projects
 > WORKDIR = $(BASEDIR)/src/test
 >  SRCDIR = $(WORKDIR)
 >  LIBDIR = $(BASEDIR)/lib
 >  OBJDIR = $(WORKDIR)
 >
 > LIBRARY = $(LIBDIR)/test.$(SO_EXT)
 >
 >    OBJS = \
 >  $(OBJDIR)/test.$(OBJ_EXT)
 >
 > all :: $(LIBRARY)
 >
 > $(OBJDIR)/test.$(OBJ_EXT) : $(SRCDIR)/test.c
 >  $(CXX) $(CXXFLAGS) -o $@ -c $(SRCDIR)/test.c
 >
 > $(LIBRARY) : $(OBJS)
 >  $(LD) $(LDFLAGS) -o $@ $(LOADLIBES) $(OBJS)
 >
 > clean ::
 >  $(RM) $(OBJS) $(LIBRARY) a.out core

 --
 -----------------------------------------------------------------------
 Jochen Loewer             HP - CSDE Boeblingen        778-6882 (TELnet)
 mailto:jochen_loewer@bbn.hp.com           ++49-(0)7031-14-6882  (phone)
 -----------------------------------------------------------------------

Last modified
1999-09-27

(195.108.246.50)

Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated