Only for the true TCL die hard.

0 views
Skip to first unread message

cracker31

unread,
May 19, 1999, 3:00:00 AM5/19/99
to
I have a very complicated problem relating to the creation of shared
libraries on HP 10.20. I am trying to create a shared library and have
it loadable by TCL. From within my shared library I have references to
third party shared libraries that are wrote in c++.
I am able to build the my shared library but TCL fails to load it.
I modified the TCL source and recompiled it so it would spit out what is
going on when it tries to load my shared library. It fails on the
symbol __shlinit which can be found in the libCsup.sl file. So I tried
to link in that file and then I get the symbol __staticCtortable_Start
(data) as unresolved.
To get around this I recompiled the TCL source again, using the
option "BIND_DEFERRED" for the shl_load call that is made in the file
tclLoadShl.c. This appears to have worked except now when I make a call
to any of the TCL functions that I wrote, which uses the third party
Shared Library, I get a Bus error.
I am writing just a basic shared library with no main and no
Tcl_main defined. This same library when compiled on NT as a dll works
fine.
I believe my problem is related to my mis-understanding (or lack) of
what is going on when I am compiling the library. I have read a lot of
information on what happens when you compile a shared library but I
still can't figure this one out.

Any help would be appreciated?
A good example of how to create a shared library which makes calls to a
c++ library would be useful.

P.S. I have mainly been trying to compile this using the aCC compiler.


David Woodbury

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

cracker31 wrote:

> I have a very complicated problem relating to the creation of shared
> libraries on HP 10.20. I am trying to create a shared library and have
> it loadable by TCL. From within my shared library I have references to
> third party shared libraries that are wrote in c++.
> I am able to build the my shared library but TCL fails to load it.
> I modified the TCL source and recompiled it so it would spit out what is
> going on when it tries to load my shared library. It fails on the
> symbol __shlinit which can be found in the libCsup.sl file. So I tried
> to link in that file and then I get the symbol __staticCtortable_Start
> (data) as unresolved.
>

Tcl's load command is not compatible with C++ shared libraries that
construct and destruct C++ objects. You'll need to use the un-documented
function cxxshl_load, in place of the shl_load command. Check out the
online help for CC using the +help option. There's a brief mention of this
issue.

Hope this helps !

--
David Woodbury IT CIM Solutions
Email: mailto:r28...@email.sps.mot.com Motorola SPS
voice: 602-914-8194 426 North 44 Street
fax: 602-914-8130 Gateway 1, Suite 250
pager: 888-782-2096 Phoenix, AZ 85008
pager: http://www.skytel.com/paging/pageme.cgi?pin=7822096,2


Scott Redman

unread,
May 20, 1999, 3:00:00 AM5/20/99
to
To save everyone from searching....I kept the
message locally, here is a copy of how to fix
the C++ loading on HP:

-- Scott

ur...@my-dejanews.com wrote:
>
> Frank Pilhofer <f...@informatik.uni-frankfurt.de> wrote:
>
> > And there's no need to. There is only one problem where compiling Tcl
> > with a C++ compiler has an effect, and that's HP-UX, where loadable C++
> > modules simply don't work if main() is not compiled with aCC.
>
> We found that it *is* possible to load C++ extensions on HP-UX though we
> don't have aCC.
>
> The most important secret you've to know about is the
>
> cxxshl_load()
>
> function which is a sibling of shl_load(), organizing correct
> initializations of C++ instances. In short, you've to patch
> the tclLoadShl.c module:
>
> (1) #include <cxxdl.h>
> ... then shl_t cxxshl_load(const char *path, int flags,
> long address);
> is declared.
>
> (2) Replace the shl_load()
>
> - handle = shl_load(fileName, BIND_IMMEDIATE, 0L);
> + handle = cxxshl_load(fileName, BIND_IMMEDIATE, 0L);
>
> (or even *much* better:)
> + handle = cxxshl_load(fileName, BIND_IMMEDIATE|BIND_VERBOSE, 0L);
>
> Note: the shlcxx_load function is in /opt/CC/libC.1 which is
> automagically linked into C++ executables.
>
> If tclLoadShl.c is *not* patched, I don't see any chance to load
> explicitly a C++ extension into a native tclsh executable.
>
> With HP specific patches (see above), you may compile Tcl's main()
> with cc. When linking you should add the following flags
>
> -E -L/opt/CC/lib -lC -lcxx
>
> The -E is to "Mark all symbols defined by a program for export
> to shared libraries."
>
> --Ulrich
>
> PS: I learned most of that from Martin Hofmann (u...@daveg.com) who did
> the research on the issue.
>
> Ulrich Ring, Daveg GmbH Darmstadt (Germany) - u...@daveg.com
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

lvi...@cas.org

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

According to Scott Redman <red...@scriptics.com>:
:To save everyone from searching....I kept the

:message locally, here is a copy of how to fix
:the C++ loading on HP:

Scott - is this going into the Tcl 8.1.1 porting file?

--
<URL: mailto:lvi...@cas.org> Quote: Saving the world before bedtime.
<*> O- <URL: http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.

pin...@my-deja.com

unread,
Jun 9, 1999, 3:00:00 AM6/9/99
to
In article <3742B139...@geocities.com>,

cracker31 <crac...@geocities.com> wrote:
> I have a very complicated problem relating
to the creation of shared
> libraries on HP 10.20. I am trying to create a
shared library and have
> it loadable by TCL. From within my shared
library I have references to
> third party shared libraries that are wrote in
c++.
> I am able to build the my shared library
but TCL fails to load it.
> I modified the TCL source and recompiled it so
it would spit out what is
> going on when it tries to load my shared
library. It fails on the
> symbol __shlinit which can be found in the
libCsup.sl file. So I tried
> to link in that file and then I get the symbol
__staticCtortable_Start
> (data) as unresolved.
> To get around this I recompiled the TCL
source again, using the
> option "BIND_DEFERRED" for the shl_load call
that is made in the file
> tclLoadShl.c. This appears to have worked
except now when I make a call
> to any of the TCL functions that I wrote, which
uses the third party
> Shared Library, I get a Bus error.
> I am writing just a basic shared library
with no main and no
> Tcl_main defined. This same library when
compiled on NT as a dll works
> fine.
> I believe my problem is related to my mis-
understanding (or lack) of
> what is going on when I am compiling the
library. I have read a lot of
> information on what happens when you compile a
shared library but I
> still can't figure this one out.
>
> Any help would be appreciated?
> A good example of how to create a shared

library which makes calls to a
> c++ library would be useful.
>
> P.S. I have mainly been trying to compile this
using the aCC compiler.
>
>
Hi,
My name is ping Lu (new to TCL /C), I am
interesting in writing extention with C
in Packages format .
there are several questions for you
1.I find in other to Compile as shared library
on Solaris as folowing:
cc -K -c rdb.c
ld -G -z text rdo.o -o rdb.so
It'seems no nessary to link with tcllib, isn't
it ? (suppose rdo.c include tcl.h )
2. I work at AIX , my cc don't support -K, so I
try follow:
cc -c rdb.c
ld -G -z rdb.o -lm rdb.so
the second step has following error and warn:
ld: 0711-327 WARNING: Entry point not found:
__start
ld: 0711-244 ERROR: No csects or exported symbols
have been saved.
(acturally I used randompkg.c to replace rdb.c ,
this is a example of Brent B. Welch' s
book "practical Programming in Tcl and TK"
I try to use ld -G -z text rdb.o -ordb.so
ld: 0706-005 Cannot find or open file: text
ld:open(): No such file or directory
Wolud you mind giving some advice about 1.
nessary or not link tcl library
2. how to do it at AIX ?
Thank you vary much !
ping Lu
404 South 40th Street #8
Omaha, NE 68132

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Reply all
Reply to author
Forward
0 new messages