Re: .so and .a libs, tcl, postgres = in over my head
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:
I made a few mistakes in transcribing this, some was cut and paste,
and some I just wrote. For the record, the script I was trying to
run in all cases, unless otherwise noted was:
> >load libpgtcl.so
> >puts "hello world"
> >Everything is ok so far...
> >
> >But, when I compile like so:
> >gcc -o mytclsh mytclsh.c /usr/lib/tcl8.0.a -lm -ldl
> ^^^
> I have /usr/lib/libtcl8.0.a; is that what you mean?
Yes.
> >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)
>
> So there's something different about tcltest.tcl? What is on its first
> line? If that is `load libpgtcl.so', you must have a problem in that
> there is no code in your object file for loading the libpgtcl shared
> library.
Yes, the 'load' command dies.
> >I've given a look at this, but...frankly, I'm a bit lost between all
> >the static and dynamic and what not.
> >
> >So.. hrmmm.. is this a problem with the postgres... tcl.. me?
> >
> >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)
> >
> >Hrmm.. linking against libcrypt.a does not improve anything...
>
> I'm far from understanding all the ins and outs of shared v. static
> libraries, but it looks to me as if you have a kind of sub-process that
> is being run in one case but not in the other.
>
> Try this:
>
> gcc -o mytclsh mytclsh.c -static -ltcl8.0 -shared -lm -ldl
@hrothgar [~] $gcc -g -o mytclsh mytclsh.c -static -ltcl8.0 -shared
-lm -ldl
mytclsh.c: In function `main':
mytclsh.c:12: warning: passing arg 3 of `Tcl_GetVar' makes integer
from pointer without a cast
@hrothgar [~] $mytclsh tcltest.tcl
Segmentation fault (core dumped)
Here is an strace:
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.
> in case the compiler is better able to handle things if it is told what
> is happening.
>
> On the other hand, it might be that it is impossible to load a shared
> library from inside a static library.
I'm guessing that maybe it's something like this, but.. I just don't
know enough to reason this out on my own. I'm not even really sure
where I might begin reading to learn more...
> Oliver Elphick
> postgresql maintainer
Your postgresql package is excellent, thanks:-)))
Thanks,
--
David Welton http://www.efn.org/~davidw
Debian GNU/Linux - www.debian.org
--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: