Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: michams on September 06, 2006, 04:48:57 pm

Title: DLL with alias function names
Post by: michams on September 06, 2006, 04:48:57 pm
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:

Code
bool DistributeValue(int *pValues)

which is exported automatically as

Code
_Z15DistributeValuePi

In VisualC++ its enough to place a def file with the alias in the source folder
Code
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
Title: Re: DLL with alias function names
Post by: mandrav on September 06, 2006, 05:35:28 pm
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).
Title: Re: DLL with alias function names
Post by: michams on September 07, 2006, 08:17:27 am
Hm, neither the first nor the second method has an effect to the exported symbols in my dll...  :?
Title: Re: DLL with alias function names
Post by: tiwag on September 07, 2006, 08:46:15 am
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

Code
#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
Title: Re: DLL with alias function names
Post by: tiwag on September 07, 2006, 11:26:45 am
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]
Title: Re: DLL with alias function names
Post by: severach on September 11, 2006, 12:26:41 am
http://wyw.dcweb.cn/stdcall.htm