You need to turn off the mangler by identifying each function as extern "C":
-
extern "C" int MyFunciton()
-
{
-
-
};
-
Have you done this?
Of course, you lose function oveloading but a DLL is an old C thing and there is no function overloading in C.
Alternaltively, you could add a .DEF file to your DLL project and in there you can export the mangled name as something else. This will allow you to use function overloading in C++ but each overload will be in the DLL as a unique name as specified in the DEF file:
-
;BEGIN ADLL.DEF FILE
-
;This DEF file is required because the argument to GetProcAddress()
-
;for the function is a C-string and it will never be equal to the
-
;C++ mangled name for the function
-
;This DEF file maps the mangled name to a name that can be used with GetProcAddress()
-
;Note also: Change project settings in Visual Studio to send the LINK this def file.
-
;Visual Studio.NET: Project Properties/Linker/Input/Module Definition File/...Path to the def file\Adll.def
-
LIBRARY ADll
-
EXPORTS
-
;Exported Name C++ Mangled Name
-
AreaOfSquare = ?AreaOfSquare@@YGHHH@Z
-
DisplayFromDll = ?DisplayFromDll@@YGXXZ
-
;END DEF FILE
-
Please note the project settting in the example above os the linker can find the DEF file.