HELP: Creating TCL loadable modules in HP

1 view
Skip to first unread message

cracker31

unread,
May 5, 1999, 3:00:00 AM5/5/99
to
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

unread,
May 6, 1999, 3:00:00 AM5/6/99
to cracker31
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.

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

Matt Newman

unread,
May 6, 1999, 3:00:00 AM5/6/99
to
Jochen Loewer wrote in message <3731DCED...@bbn.hp.com>...

>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.


THANKYOU! This has been bugging me for some time but I never got around to
looking into it.

Great patch!!!!!

Matt

Marc Rossi

unread,
May 19, 1999, 3:00:00 AM5/19/99
to
In comp.lang.tcl cracker31 <crac...@geocities.com> 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.

Try adding -Wl,+s,+b,path_to_installed_tcl_libs onto your LDFLAGS. Make
sure you use the path where you have installed the Tcl libs (such as
/usr/local/tcl/lib), not where you built
Tcl. We added the BIND_VERBOSE flag to the shl_load() call in tclLoadShl.c
before building our Tcl distribution so we can get a little better idea
of what the problem is when a load fails without having to resort to nm
and other tactics.

Hope this helps,
Marc

--
Marc Rossi
mailto:ma...@mcs.com

Ibrahim Khalil

unread,
May 19, 1999, 3:00:00 AM5/19/99
to
Does anyone know the existence of any TCL/TK video display software ? I have
stored sequence of
JPEG (or GIF, XBM etc) pictures cpatured from video camera. Now if I can
display those on a canvas
at the rate of 24 (or more or less) JPEG pictures per second then I should be
able to have some
visual effects. If anyone knows about any such software or of any video
conferencing software
pls let me know

Regards,
Ibrahim khalil

ldup...@cmocbx.qc.bell.ca

unread,
May 20, 1999, 3:00:00 AM5/20/99
to

Well, there is an MPEG library freely available somewhere and there is an
mpeg_encode program lying around somewhere on the 'Net so you could
conceivably use the latter to create your movies and create a Tcl extension
for the former.

Before doing so, Id' go check http://www.purl.org/net/Tcl-FAQ/part4.html and
part5.html to see if that hasn't already been done.

L

--
Penguin Power! Nothing I say reflects the views of my employer

Laurent Duperval mailto:laurent....@cgi.ca
CGI - SARM Project Phone: (514) 391-9523

Reply all
Reply to author
Forward
0 new messages