[Redirected to gcc-help@xxxxxxxxxxx: plese don't post questions like this to gcc@] summer xia writes: > I am porting a application from Windows into Linux. The application > has many modules that wrote by different persons. There are some > files or classes named the same name with different implement. Such > as the library A has the class CSky, the libary B has the class > CSky too. But these classes have the different implement. There is > no any errors when I complie the library A and library B into share > libraries. But when I use these libraries. I alway find that the > gcc link the error class(I use the gdb to debug it), such as when I > use the class CSky in the module B, I suppose that this class > should use this module internal implement( this is to say use CSky > implement in the library B). But it is surprised to me that CSky > uses the library A implement. It's part of the language rules. If there exists a function or an object called foo, &foo must always return the same pointer no matter where it is referenced from. So, at load time your shared libraries are scanned, and the first instance of foo is found, and that same foo is used everywhere. You can control what symbols are exported from a shared library by using a version script: -E --export-dynamic When creating a dynamically linked executable, add all symbols to the dynamic symbol table. The dynamic symbol table is the set of symbols which are visible from dynamic objects at run time. If you do not use this option, the dynamic symbol table will nor- mally contain only those symbols which are referenced by some dynamic object mentioned in the link. If you use "dlopen" to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other dynamic object, then you will probably need to use this option when linking the program itself. You can also use the version script to control what symbols should be added to the dynamic symbol table if the output format supports it. See the description of --version-script in VERSION. You can also use namespaces. This is probably your best plan. Andrew.