[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hypermail
Subject:    [hypermail] link a program with two libraries that use same global variable
From:       "AMMAR,LAMIA (HP-USA,ex1)" <lamia.ammar () hp ! com>
Date:       2002-11-08 15:58:28
[Download RAW message or body]

Suppose you have two libraries and both libraries include a declaration
of a global variable "abc".  You need to link both libraries into your
executable.  One is available only as a shared library, libO.sl.  The
other is available as either libN.a  or libN.sl, your choice.

Assume that the declarations for abc in the two libraries are
incompatible -- maybe one is an int, and the other is *char.   When you
link these two libraries with your program, I believe that by default
all the references to abc from both libraries will resolve to one
instance of abc, either the int or the *char.  This won't work well :-).

Which instance of abc is used, and what happens when you run the program
depends on (at least) the order the libraries are searched, whether libN
is an archive or shared library, and how the references to abc happen to
occur.

Let me know if there is a workaround for this.
Thanks
Lamia

------------------------------------
Lamia Mansour Ammar
Sr. Technical Consultant
Software Services
HP Consulting
404.774.4022
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic