This is the mail archive of the
mailing list for the GCC project.
Re: How to make gcc give a check about symbol conflicts in shared libraries it links?
- From: Ian Lance Taylor <iant at google dot com>
- To: "xiaxia347work"<xiaxia347work at 163 dot com>
- Cc: "gcc-help"<gcc-help at gcc dot gnu dot org>
- Date: Mon, 07 Nov 2011 07:32:44 -0800
- Subject: Re: How to make gcc give a check about symbol conflicts in shared libraries it links?
- References: <ea915dc.cde40.1337cfc2d85.Coremail.email@example.com>
> I got a tricky problem when I link my exe program with 2 shared libraries,
> the global variable with same name in the 2 .so file may be linked to the same
> address, resulting problem that is hard to find.
This is not a gcc issue.
You didn't mention which OS you are using. I will assume it is
GNU/Linux. On GNU/Linux, or any other ELF based system, there is a
single global namespace of global variables and functions. When two
shared libraries use the same global variable name, they are referring
to the same variable. This is a feature.
If you want something different to happen, look into symbol visibility
and linker version scripts.