Re: .so and .a libs, tcl, postgres = in over my head
All right, having seen this behavior recently (in libapache-mod-perl,
still sitting in incoming waiting for an override file editing :), I'll
take a stab at this.
On Wed, Jul 01, 1998 at 09:42:05AM -0700, David Welton wrote:
> First, thanks to yourself and Stephen Zander for your replies:-)
>
> On Wed, Jul 01, 1998 at 08:19:09AM +0200, Oliver Elphick wrote:
> > David Welton wrote:
> > ...
> > >Compiled with gcc -o mytclsh mytclsh.c -ltcl8.0, it seems to work
> > >pretty well, when run like this:
> > >
> > >mytclsh foobar.tcl, where foobar.tcl is this:
This seems to make sense to me...
> > >It can run "normal" tcl programs, like
> > >puts "hello world", but it seems to choke on the load, like this:
> > >@hrothgar [~] $mytclsh tcltest.tcl
> > >couldn't load file "libpgtcl.so": /usr/lib/libpgtcl.so: undefined
> > >symbol: Tcl_GetChannel
> > > while executing
> > >"load libpgtcl.so"
> > > (file "tcltest.tcl" line 1)
The first question is whether the symbol is present. If it is, it's a
scope problem; if it isn't, it's a linker problem.
> > >Interesting.. I try compiling like this:
> > >gcc -o mytclsh mytclsh.c /usr/lib/tcl8.0.a /usr/lib/libm.a /usr/lib/libdl.a
> > >
> > >and I get:
> > >@hrothgar [~] $mytclsh tcltest.tcl
> > >couldn't load file "libpgtcl.so": /lib/libcrypt.so.1: undefined symbol:
> > > _ufc_foobar
> > > while executing
> > >"load libpgtcl.so"
> > > (file "tcltest.tcl" line 1)
You probably don't want to do that. I can see a reason for linking
statically, to libtcl, but you shouldn't statically link to libraries
you know will be available unless absolutely necessary.
> @hrothgar [~] $gcc -g -o mytclsh mytclsh.c -static -ltcl8.0 -shared
> -lm -ldl
[snip]
> execve("./mytclsh", ["mytclsh", "tcltest.tcl"], [/* 21 vars */]) = 0
> --- SIGSEGV (Segmentation fault) ---
> +++ killed by SIGSEGV +++
>
> Wow, that's the fastest I've ever seen anything die.
Errors that early refer to linking problems. In this case : -shared is
meant only for use in actual .so's. I am guessying that the flag you
want is -rdynamic, judging from various makefiles lying around. Try:
gcc -g -o mytclsh mytclsh.c -rdynamic -ltcl8.0 -lm -ldl
> > On the other hand, it might be that it is impossible to load a shared
> > library from inside a static library.
It can be done. libperl.a is statically linked in when perl is built,
and contains the dlopen stubs perl uses.
Dan Jacobowitz
drow@false.org
--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: