NO

Author Topic: Name Mangling in Pelles C?  (Read 3511 times)

edprue

  • Guest
Name Mangling in Pelles C?
« on: November 19, 2011, 09:30:45 PM »
I built a static library using a Pelles C project.  I have an app using a Pelles C project.  I've added the name of my library to the "Linker" tab of my app project settings.  When I build my app, I get the linker error "POLINK: error: Unresolved external symbol  '_edpDbfOpen'." 'edpDbfOpen' (no prepended underscore) is the name of one of my library functions.  When I do a PODUMP on my library, I find this (amongst other things):

   _edpDbfOpen@12

In my experience, that's name mangling.  I can't find any information (via Google) about Pelles C doing name mangling.  Maybe it's not name mangling, but something to do with the way static libs work on Win32 (not my area of expertise.)  I'd appreciate any help that anyone can offer.  Thanks.

Ed Prue

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Name Mangling in Pelles C?
« Reply #1 on: November 19, 2011, 11:00:18 PM »
I built a static library using a Pelles C project.  I have an app using a Pelles C project.  I've added the name of my library to the "Linker" tab of my app project settings.  When I build my app, I get the linker error "POLINK: error: Unresolved external symbol  '_edpDbfOpen'." 'edpDbfOpen' (no prepended underscore) is the name of one of my library functions.  When I do a PODUMP on my library, I find this (amongst other things):

   _edpDbfOpen@12

In my experience, that's name mangling.  I can't find any information (via Google) about Pelles C doing name mangling.  Maybe it's not name mangling, but something to do with the way static libs work on Win32 (not my area of expertise.)  I'd appreciate any help that anyone can offer.  Thanks.

Ed Prue
C doesn't do name "mangling", that's only in C++ and other OO oriented languages. In C however name "decoration" exists and needs to fit the convention of the target environment.

You have a mismatch in the naming/calling convention between the library you created and and the application you are trying to link that library to. One is likely STDCALL, the other CDECL. Adjust as needed...

Ralf
« Last Edit: November 21, 2011, 12:29:20 AM by Bitbeisser »

edprue

  • Guest
Re: Name Mangling in Pelles C?
« Reply #2 on: November 20, 2011, 03:48:20 AM »
Thanks, Ralf.  I figured I was missing something basic like that.  I actually hovered my mouse over the calling convention drop-down in my project settings earlier today, but was afraid I might see smoke come out of my laptop (the sign of a timid soul, I fear.). Thanks for your guidance.

- Ed

Offline Vortex

  • Member
  • *
  • Posts: 867
    • http://www.vortex.masmcode.com
Re: Name Mangling in Pelles C?
« Reply #3 on: November 20, 2011, 10:02:06 AM »
Hi Ed,

Pelles C adopts Microsoft's name decoration convention. Have a look at Agner Fog's work : Calling conventions for C++ compilers

Quote
Calling conventions for different C++ compilers and operating systems
This document contains details about data representation, function calling conventions, register usage conventions, name mangling schemes, etc. for many different C++ compilers and operating systems. Discusses compatibilities and incompatibilities between different C++ compilers. Includes information that is not covered by the official Application Binary Interface standards (ABI's). The information provided here is based on my own research and therefore descriptive rather than normative. Intended as a source of reference for programmers who want to make function libraries compatible with multiple compilers or operating systems and for makers of compilers and other development tools who want their tools to be compatible with existing tools.
 
File name: calling_conventions.pdf, size: 414709, last modified: 2011-Jun-08.

http://agner.org/optimize/calling_conventions.pdf
Code it... That's all...

Ray of Light

  • Guest
Re: Name Mangling in Pelles C?
« Reply #4 on: February 06, 2012, 06:25:51 PM »
Greetings!

What do we do if the library is a third-party library and we wish to call a function in the DLL?
(In my case, I wish to link to the IB_UTIL.DLL that is part of Firebird to call the ib_util_malloc function.)

-Ray.
« Last Edit: February 06, 2012, 06:28:25 PM by Ray of Light »