[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: .so and .a libs, tcl, postgres = in over my head



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

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.

Oliver Elphick
postgresql maintainer

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "Because he himself suffered when he was tempted, he
      is able to help those who are being tempted."       
                                        Hebrews 2:18 



--  
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: