User forums > Using Code::Blocks

DLL with alias function names

(1/2) > >>

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:


--- Code: ---bool DistributeValue(int *pValues)
--- End code ---

which is exported automatically as


--- Code: ---_Z15DistributeValuePi
--- End code ---

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

--- Code: ---EXPORTS
   DistributeValue
--- End code ---

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).

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

tiwag:
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
--- End code ---


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]

Navigation

[0] Message Index

[#] Next page

Go to full version