NO

Author Topic: Decoration  (Read 5094 times)

czerny

  • Guest
Decoration
« on: July 16, 2014, 11:10:40 AM »
I need some instructions concerning function decoration! I always have problems with that stuff.  :-[

I have some code which should link with the statistical software R 3.1.0

There exists a DLL an import library and the header files.

In the code I have used the function 'Rf_initEmbeddedR' with cdecl as project option.
Polink searches for '_Rf_initEmbeddedR' regardless of which switch is set -Gm or -Gn

I have tryed to explore the DLL and the LIB with podump /EXPORT

In the DLL: 23C   23B  6C70C0A0  Rf_initEmbeddedR
In the LIB: R.dll: _Rf_initEmbeddedR (__Rf_initEmbeddedR)

So there are the following questions:

How is it possible to avoid any decoration?
Neither the first entry nor the second (in braces) of the LIB is matching with the entry in the DLL. Why?
Which, the first or the second, should match? Or in other words: which is the exported name, which the name in the DLL?

EDIT: I suppose that the import library and DLL is produced by/for mingw. What are the differences?
« Last Edit: July 16, 2014, 11:31:29 AM by czerny »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Decoration
« Reply #1 on: July 16, 2014, 05:37:35 PM »
If you have time read this.
Try to rebuild your import library using:
polib mylibrary.dll /OUT:mylibrary.lib
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

czerny

  • Guest
Re: Decoration
« Reply #2 on: July 16, 2014, 06:48:29 PM »
polib mylibrary.dll /OUT:mylibrary.lib
Now it looks:

R.dll: Rf_initEmbeddedR (Rf_initEmbeddedR)

but the linker is always claiming for '_Rf_initEmbeddedR'

Offline Vortex

  • Member
  • *
  • Posts: 797
    • http://www.vortex.masmcode.com
Re: Decoration
« Reply #3 on: July 16, 2014, 07:40:07 PM »
You can try the NOUND option of Polib :

Quote
/NOUND   Don't add underscore to import names
Code it... That's all...

czerny

  • Guest
Re: Decoration
« Reply #4 on: July 17, 2014, 08:02:22 AM »
You can try the NOUND option of Polib :
Quote
/NOUND   Don't add underscore to import names
This is by default! See (Yesterday at 05:48:29 PM).

Once more, I need to know what is what in the output of podump.

I propably need:
R.dll: Rf_initEmbeddedR (_Rf_initEmbeddedR)
or vice versa
R.dll: _Rf_initEmbeddedR (Rf_initEmbeddedR)

Dumpbin differentiates between 'function names' and 'symbol names'. Is it right, that Podump writes the second one in brackets?

How can I either prevent that the compiler uses underscrores in front of symbol names or produce an import library with underscores in symbol names.

Why is in the original import library the function name decorated by a single underscore, the symbol name decorated by two underscores, while the exported DLL name has no underscore at all in front of there names? Is this normal for mingw librarys?
« Last Edit: July 17, 2014, 08:20:21 AM by czerny »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Decoration
« Reply #5 on: July 17, 2014, 10:20:36 AM »
In the header file specify that it is an imported function:
I.e. change from
Code: [Select]
int my func(int a);to
Code: [Select]
__declspec(dllimport) int my func(int a);
If still you cannot link you have to define aliases in a def module:
As told in the previous post create your import library:
Code: [Select]
polib mydll.dll /OUT:MyDll.libThen get the definition file from library:
Code: [Select]
polib myDll.lib /MAKEDEF:MyDll.defEdit the definition file adding your aliases:
Code: [Select]
LIBRARY "MyDll.dll"
EXPORTS
Rf_initEmbeddedR    ;Original export
_Rf_initEmbeddedR = Rf_initEmbeddedR    ; ALIAS. Now you will have two functions with different names
.......                                                             ;calling the same function
.......
Rebuild the import library with:
Code: [Select]
polib MyDll.lib /DEF:MyDll.defNow you have a new import library with all required aliases.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

czerny

  • Guest
Re: Decoration
« Reply #6 on: July 17, 2014, 11:05:22 AM »
I am very confused:
Code: [Select]
polib mydll.dll /OUT:MyDll.lib
Code: [Select]
polib myDll.lib /MAKEDEF:MyDll.defEdit the definition file adding your aliases:
Code: [Select]
LIBRARY "MyDll.dll"
EXPORTS
Rf_initEmbeddedR    ;Original export
_Rf_initEmbeddedR = Rf_initEmbeddedR    ; ALIAS. Now you will have two functions with different names
.......                                                             ;calling the same function
.......
Rebuild the import library with:
Code: [Select]
polib MyDll.lib /DEF:MyDll.def
After the first step:
Code: [Select]
polib mydll.dll /OUT:MyDll.libI have : R.dll: Rf_initEmbeddedR (Rf_initEmbeddedR)
After the other steps without editing anything I have: R.dll: Rf_initEmbeddedR (_Rf_initEmbeddedR)

Can someon explain?
« Last Edit: July 17, 2014, 11:07:03 AM by czerny »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Decoration
« Reply #7 on: July 17, 2014, 06:18:25 PM »
After the other steps without editing anything I have: R.dll: Rf_initEmbeddedR (_Rf_initEmbeddedR)

Can someon explain?
:(
It seems that, when using a def file, polib itself automatically generate correct decorated symbols...
But you haven't told us if you can link the DLL now!
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide