Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Difference in mangling

Reply
Thread Tools

Difference in mangling

 
 
lomat
Guest
Posts: n/a
 
      07-29-2003
Hello,

I am using VisiBroker 4.0 on RedHat 8.0 with GCC 3.2.

When I do a "nm liborb_r.so | grep _invoke", I get some output. The symbol
of my intrest is manged as below,
002f6270 T _preinvoke__12CORBA_ObjectPCc

Now when I build an app that links to liborb_r.so, and uses the _preinvoke
API, GCC mangles this symbol as follows,
U _ZN12CORBA_Object10_preinvokeEPKc

In short, (as mangling is compiler dependent) my compiler is mangling the
symbols in a way different from the compiler that was used to build the
library I am trying to link to. As a result I am getting an un-resolved
symbol error. How do I solve this?

Thanks in advance,

Loma



 
Reply With Quote
 
 
 
 
Andrew Koenig
Guest
Posts: n/a
 
      07-29-2003
lomat> In short, (as mangling is compiler dependent) my compiler is
lomat> mangling the symbols in a way different from the compiler that
lomat> was used to build the library I am trying to link to. As a
lomat> result I am getting an un-resolved symbol error. How do I solve
lomat> this?

Suppose the names happened to be mangled the same way. What makes
you think that the compiler you are using to compile your program
would use the same binary calling conventions as the compiler that
was used to build the library?

--
Andrew Koenig,
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-29-2003
"lomat" <> wrote...
> I am using VisiBroker 4.0 on RedHat 8.0 with GCC 3.2.
>
> When I do a "nm liborb_r.so | grep _invoke", I get some output. The symbol
> of my intrest is manged as below,
> 002f6270 T _preinvoke__12CORBA_ObjectPCc
>
> Now when I build an app that links to liborb_r.so, and uses the _preinvoke
> API, GCC mangles this symbol as follows,
> U _ZN12CORBA_Object10_preinvokeEPKc
>
> In short, (as mangling is compiler dependent) my compiler is mangling the
> symbols in a way different from the compiler that was used to build the
> library I am trying to link to. As a result I am getting an un-resolved
> symbol error. How do I solve this?


Name mangling is compiler-specific. If two different compilers are
used to build the library and the executable, they (the library and
the executable) are not guaranteed to be compatible. C++ is only
portable on the source code level. There are two ways to solve your
problem: recompile both the library and the executable using the
same compiler OR build some kind of interface guaranteed not to have
its name mangled, e.g. by declaring it 'extern "C" '.

Victor


 
Reply With Quote
 
lomat
Guest
Posts: n/a
 
      07-29-2003


- I do not have source code for liborb_r.so (it comes with Borland
VisiBroker) and we have purchased it.
- There's a problem with writing a bridge. I am not sure if I can explain it
well. *I do not know all the functions that my application will use from
this library*. It's a CORBA thing. For e.g. the function _preinvoke() I
mentioned in my earlier example isn't being called from my code directly. I
call some API which (I think) in turn call this _preinvoke() internally.

Any other suggestions? Thanks!

Loma

"Victor Bazarov" <> wrote in message
news:...
> "lomat" <> wrote...
> > I am using VisiBroker 4.0 on RedHat 8.0 with GCC 3.2.
> >
> > When I do a "nm liborb_r.so | grep _invoke", I get some output. The

symbol
> > of my intrest is manged as below,
> > 002f6270 T _preinvoke__12CORBA_ObjectPCc
> >
> > Now when I build an app that links to liborb_r.so, and uses the

_preinvoke
> > API, GCC mangles this symbol as follows,
> > U _ZN12CORBA_Object10_preinvokeEPKc
> >
> > In short, (as mangling is compiler dependent) my compiler is mangling

the
> > symbols in a way different from the compiler that was used to build the
> > library I am trying to link to. As a result I am getting an un-resolved
> > symbol error. How do I solve this?

>
> Name mangling is compiler-specific. If two different compilers are
> used to build the library and the executable, they (the library and
> the executable) are not guaranteed to be compatible. C++ is only
> portable on the source code level. There are two ways to solve your
> problem: recompile both the library and the executable using the
> same compiler OR build some kind of interface guaranteed not to have
> its name mangled, e.g. by declaring it 'extern "C" '.
>
> Victor
>
>



 
Reply With Quote
 
lomat
Guest
Posts: n/a
 
      07-29-2003
This didn't strike me earlier, I am not a compiler internals pro yet.
You have any possible solution(s) ?

Loma

"Andrew Koenig" <> wrote in message
news:...
> lomat> In short, (as mangling is compiler dependent) my compiler is
> lomat> mangling the symbols in a way different from the compiler that
> lomat> was used to build the library I am trying to link to. As a
> lomat> result I am getting an un-resolved symbol error. How do I solve
> lomat> this?
>
> Suppose the names happened to be mangled the same way. What makes
> you think that the compiler you are using to compile your program
> would use the same binary calling conventions as the compiler that
> was used to build the library?
>
> --
> Andrew Koenig,



 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      07-29-2003
lomat wrote:

> - I do not have source code for liborb_r.so (it comes with Borland
> VisiBroker) and we have purchased it.
> - There's a problem with writing a bridge. I am not sure if I can
> explain it well. *I do not know all the functions that my application
> will use from this library*. It's a CORBA thing. For e.g. the function
> _preinvoke() I mentioned in my earlier example isn't being called from
> my code directly. I call some API which (I think) in turn call this
> _preinvoke() internally.
>
> Any other suggestions? Thanks!


Either find out which compiler the library was compiled with and use the
same one or ask the manufacturer if he can compile the library with
your compiler.

 
Reply With Quote
 
Shane McDaniel
Guest
Posts: n/a
 
      07-29-2003

There really isn't any other good way than recompiling everything with
the same compiler. The problem is that compilerss are not required to
name mangle the same, and therefor you can not gaurante that object code
from two different compilers will work. In fact g++ 3.1 and g++ 3.2
object code isn't even compatible, so it's not just different compilers
but possible different versions too.

lomat wrote:
>
> - I do not have source code for liborb_r.so (it comes with Borland
> VisiBroker) and we have purchased it.
> - There's a problem with writing a bridge. I am not sure if I can explain it
> well. *I do not know all the functions that my application will use from
> this library*. It's a CORBA thing. For e.g. the function _preinvoke() I
> mentioned in my earlier example isn't being called from my code directly. I
> call some API which (I think) in turn call this _preinvoke() internally.
>
> Any other suggestions? Thanks!
>
> Loma
>

 
Reply With Quote
 
Andrew Koenig
Guest
Posts: n/a
 
      07-29-2003
Victor> There are two ways to solve your problem: recompile both the
Victor> library and the executable using the same compiler OR build
Victor> some kind of interface guaranteed not to have its name
Victor> mangled, e.g. by declaring it 'extern "C" '.

That second alternative doesn't necessarily work, because even
if two compilers use the same naming conventions, they might
use different calling sequences.

The only solution is to use two compilers that are known to be
mutually compatible.

--
Andrew Koenig,
 
Reply With Quote
 
Greg Comeau
Guest
Posts: n/a
 
      07-29-2003
In article <>,
Victor Bazarov <> wrote:
>build some kind of interface guaranteed not to have
>its name mangled, e.g. by declaring it 'extern "C" '.


Actually, that's not guaranteed, but an implementation
detail. That said, it does seem universally implemented
as not having its name mangled.
--
Greg Comeau/ 4.3.0.1: FULL CORE LANGUAGE, INCLUDING TC1
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
 
Reply With Quote
 
Greg Comeau
Guest
Posts: n/a
 
      07-29-2003
In article <bg6k36$6fc$>,
Greg Comeau <> wrote:
>In article <>,
>Victor Bazarov <> wrote:
>>build some kind of interface guaranteed not to have
>>its name mangled, e.g. by declaring it 'extern "C" '.

>
>Actually, that's not guaranteed, but an implementation
>detail. That said, it does seem universally implemented
>as not having its name mangled.


Which I should also point out does not guarantee that
the function can still be called. After all, not even
two C compilers may be able to call it, so there is
certainly no requirement that a C++ compiler must be
able to. So tred cautiously, and be aware of the
compilers, their options settings, and what the respective
vendors say about this.
--
Greg Comeau/ 4.3.0.1: FULL CORE LANGUAGE, INCLUDING TC1
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI problem: How to prevent VC++ compiler from doing name mangling abhijeet.s Java 8 02-03-2006 08:32 PM
how to handle name mangling in a shared C library Randy Yates C++ 2 01-04-2005 04:24 PM
Name-mangling standard? Tim Slattery C++ 1 09-02-2004 03:59 PM
Metaclasses for class mangling after definition. Daniele Varrazzo Python 0 07-19-2004 03:09 PM
Name Mangling in DDK sunny C++ 4 07-10-2004 01:07 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57