I have one program, it links to two libraries. There is a
variable with a same name in two different libraries. Compiler gives
multiple declaration of same variable error.
Please let me know how to resolve this error.
As others have pointed out, there's no direct way to resolve this in
standard C other than by changing the name in one of the libraries.
There *might* be some implementation-specific trick that could let you
get around this. I actually don't know of any such trick for any real
implementation, but it could exist. You might look into it (perhaps
by asking in an implementation-specific newsgroup). I'd recommend
following this path *only* if you're desperate and you can't change
either library; the resulting workaround is likely to be non-portable,
and could even break with the next release of whatever compiler you're
using.
You might consider splitting your program into two separate programs,
each one using just one of the libraries. Coordination and
communication between the two programs is likely to be tricky, and is
almost certain to be implementation-specific. This is also an
approach to be used only if you're desparate.
Whatever approach you take, you should complain bitterly to the
suppliers of both libraries. (If they're both from the same supplier,
complain *very* bitterly.)