Related articles |
---|
Solaris/g++ linking problems Slattery_T@bls.gov (2004-09-03) |
Re: Solaris/g++ linking problems ppluzhnikov@charter.net (Paul Pluzhnikov) (2004-09-07) |
Re: Solaris/g++ linking problems josejuanmr@lycos.es (Jose Juan Mendoza Rodriguez) (2004-09-07) |
From: | Jose Juan Mendoza Rodriguez <josejuanmr@lycos.es> |
Newsgroups: | comp.compilers |
Date: | 7 Sep 2004 23:56:34 -0400 |
Organization: | Me |
References: | 04-09-027 |
Keywords: | C++, linker |
Posted-Date: | 07 Sep 2004 23:56:34 EDT |
>I suspect that g++ uses a different name mangling convention than the
>Sun compiler that created the *.so files. Is this a reasonable
>diagnosis? Is there anything that can convert the *.so files into
>something that I can use?
Yes, you are right.
If you'd know the declarations of the problematic symbols, then you
could trick the compiler into thinking they are plain C external
symbols. For example, a function declared in C++ like this
void myfunc(int n, double x, char c);
will be mangled "_myfunc__Fidc" and then you put this declaration
in your source
extern "C" {
void myfunc__Fidc(int n, double x, char c);
// remove the leading underscore to bypass C mangling
}
You can learn the Sun-style mangled names from the error messages.
To avoid spoiling the source code you can use macros,
#define myfunc myfunc__Fidc
This can be a lot of work if there are many functions, but I can't
see any other way.
But unfortunately this will not be the only problem you'll encounter.
The use of scratch registers, the layout of classes, virtual tables,
virtual inheritance, etc., all this could be implemented in a
different way in each compiler, so the program will be linked ok, but
it will crash later. In practice, however, most compilers make the
same layout for lightweight classes (no virtual tables, no virtual
inheritance), and this is specially so in this case because both
compilers run on the same platform, so it's possible that you succeed
using the trick above (but don't count on it).
Regards.
José Juan Mendoza Rodríguez
Return to the
comp.compilers page.
Search the
comp.compilers archives again.