On Mon, Mar 29, 2010 at 10:40 PM, Manohar Vanga <[email protected]>wrote:
> > > On Mon, Mar 29, 2010 at 3:24 PM, Coder Bean <[email protected]> wrote: > >> >> >> On Mon, Mar 29, 2010 at 12:18 AM, Manohar Vanga <[email protected] >> > wrote: >> >>> Actually if the header file is simply included (which it was), name >>> mangling is not a problem. The function missing was called subscribe(). Here >>> are the tests: >>> >>> $ nm server | grep subscribe >>> 0804f090 T _ZN5Server6Module16subscribeEjj >>> >>> The above is the mangled name within the server binary (the function lies >>> in the Server::Module namespace). The "T" indicates that it is in the text >>> segment of the binary. >>> >>> Now, when I compile the module with the header file for the server >>> included: >>> >>> $ nm Modules/testmodule.so | grep subscribe >>> U _ZN5Server6Module16subscribeEjj >>> >>> The "U" here means this symbol is undefined. Note that the compiler >>> generated the mangled name correctly as in the server. The issue of name >>> mangling only makes a difference when different compilers are used for >>> modules and the main loader. Note that even extern "C" is not needed unless >>> compiling the two parts with different compilers. The reason for using them >>> is to have consistency across all compilers (I don't really care about this >>> as modules are part of the source and I will compile them together with the >>> main loader using one compiler). >>> >> >> I thought you wanted it to be loadable using dlopen. If you link it this >> way, main app will have dependency on the so file and therefore would >> require it while running the main app itself. If you want it to be like a >> loadable plugin, you would have to follow the approach I mentioned in my >> previous mail. Main app should never link with the plugin. Otherwise the >> whole concept of "plug-in" is useless, as you won't be able to plug-out. >> > > The main app is not linked or dependent on the plugin in any way. If you > see the nm output above, the main app has the function as a part of it. The > plugin has an undefined reference. The main app has no undefined references > and runs fine without the plugin. > > The plugin on the other hand has a dependency on the main app (which is > normal for the idea of a plugin). It has an undefined reference that gets > satisfied only when linked to the main app. The only requirement is that the > plugin and main app generate the same names for the functions. This is done > automatically if the plugin includes the declaration of the missing function > (the server header files). Name mangling doesn't come into the picture at > all. > Fine. If it solves your problem that's good. > Thanks > Manohar >

