News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

DLL with alias function names

Started by michams, September 06, 2006, 04:48:57 PM

Previous topic - Next topic

michams

Hi,

I'm building a simple dll and have a small Problem which is probably more a mingw than a CB problem. The DLL exports a function:

bool DistributeValue(int *pValues)

which is exported automatically as

_Z15DistributeValuePi

In VisualC++ its enough to place a def file with the alias in the source folder
EXPORTS
   DistributeValue


With mingw/CB this is obviously not. What will I have to do to export the function with a name I want?

Env: WinXP, CB1.0 (31.08.06), mingw32 3.4.4

mandrav

Try adding -Wl,--add-stdcall-alias in the linker options for gcc to make it for you.
Alternatively, you can create a def file and add the linker option -Wl,--def [your_def] (IIRC).
Be patient!
This bug will be fixed soon...

michams

Hm, neither the first nor the second method has an effect to the exported symbols in my dll...  :?

tiwag

#3
if you want to build a dll with import names, that are consistent between different compilers, you need
to build it as C code, which then uses the C naming conventions.

use

#ifdef __cplusplus
extern "C"
{
#endif
    .... // here are your exported function names
#ifdef __cplusplus
}
#endif



infos
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html

tiwag

her is a small project which demonstrates the differences

look at the generated .def files for name mangling info

HTH, tiwag

[attachment deleted by admin]