How to make gcc give a check about symbol conflicts in shared libraries it links?

Ian Lance Taylor
Mon Nov 7 15:33:00 GMT 2011

"xiaxia347work"<> writes:

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


More information about the Gcc-help mailing list