[kaffe] Shared library Question

Muthuswamy R muthuswamyr at aztec.soft.net
Fri Nov 29 02:25:12 PST 2002


Hi kevin,
     Ya, true that the question is in a loop. As i have been
working in this for long time, i can understand the question clearly.

Let me put it in a better way.

	I have a static library & a module (using dlopen) library. The
module library is
linked with the static library functions while creation. Now i call a
function
in the static library to set a variable. Then i access that variable through
a function
from the module library, which obviously has its own symbol table for all
the variables
in the shared library also. Now my question is how can i set a value thru'
static library
& get the same value from the module library.

      Have attached the sample files iam working with for this problem. 
The compile file is the command options to compile these files.

Thanks for helping me
mut
 

-----Original Message-----
From: Kevin D. Kissell [mailto:kevink at mips.com]
Sent: Friday, November 29, 2002 3:49 PM
To: Muthuswamy R; kaffe at kaffe.org
Subject: Re: [kaffe] Shared library Question


>     Let's say I have a shared library and a static library.
> And if i call a variable of a static library from a shared library
> the value which is previously set through a static library, the same
> copy is not there in the shared library. I mean every variable
> in the static library has a copy in the shared library. How to make
> export these values when i link the shared library to the static library
> so that, the variable has a common address space?

Your descriptoin is very confusing.  If "every variable in
the static library has a copy in the shared library", that
would seem to mean that you are building both a static
and a shared version of the same library and trying to
link with both of them at the same time, which in general
will not work.  If what you are referring to is in fact a
case of two distinct libraries which want to share a
variable, you should declare all the variables of interest
in the shared library and export them correctly.

I've never seen a non-shared global variable referenced
from within a shared library, and I would fully expect
that not to work - how is the shared library supposed
to resolve the address at runtime if the shared library
is, indeed, shared between two different applications,
each of which have that symbol at a different address?
If you need a shared library to manipulate data in a
main program or static library, you need to pass the
address of the associated storage as a parameter to
a shared library function.

What puzzles me most is that you're not getting link
errors, or at least warnings, for the multiple definitions
that you seem to have.

            Kevin K.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: file.c
Type: application/octet-stream
Size: 652 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20021129/8a4c7423/attachment-0018.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getlib.c
Type: application/octet-stream
Size: 585 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20021129/8a4c7423/attachment-0019.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: helper.h
Type: application/octet-stream
Size: 82 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20021129/8a4c7423/attachment-0020.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lib.c
Type: application/octet-stream
Size: 420 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20021129/8a4c7423/attachment-0021.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: application/octet-stream
Size: 75 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20021129/8a4c7423/attachment-0022.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compile
Type: application/octet-stream
Size: 173 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20021129/8a4c7423/attachment-0023.obj 


More information about the kaffe mailing list