GCC "Name Mangling" Prevent from Linking?
Rupert Wood
me@rupey.net
Fri Apr 12 07:01:00 GMT 2002
Chih-Wei Chiu wrote:
> I doubted it's because the compiler performed different name mangling
> scheme to my program and VTK library, and that's why linker failed.
:
> I guess the linker complained `undefined reference' because the
> function vtkMarchingCubes::New() is called New__16vtkMarchingCubes
> in VTK, while it's called _ZN16vtkMarchingCubes3NewEv in my program's
> object file.
> Why?
They were built with different C++ compilers; either different,
incompatible, versions, or from different vendors.
Different compilers implement the C++ binary interface in different ways
- the mechanisms to pass the 'this' pointer, implementation of vtables
for virtual functions, exception handling mechanisms, templating, etc.
Because the implementations are different and incompatible, they're
usually given different mangling schemes.
You can either fall back to using the same version of the compiler as
your library vendor, or you could try asking them to rebuild the library
for you with your version of the C++ compiler.
Rup.
More information about the Gcc-help
mailing list