[kaffe] Shared library Question

Kevin D. Kissell kevink at mips.com
Fri Nov 29 02:18:44 PST 2002


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




More information about the kaffe mailing list