I have compiled a DLL from a C++ Library I have written according to this tutorial.
The dumpbin for the dll is as follows:
Section contains the following exports for HelloDLL.dll
00000000 characteristics
FFFFFFFF time date stamp
0.00 version
1 ordinal base
6 number of functions
6 number of names
ordinal hint RVA name
1 0 00011032 ?Add@Functions@MathLibrary@@SANNN@Z = @ILT+45(?Add@Functions@MathLibrary@@SANNN@Z)
2 1 00011037 ?AddMultiply@Functions@MathLibrary@@SANNN@Z = @ILT+50(?AddMultiply@Functions@MathLibrary@@SANNN@Z)
3 2 000112EE ?Multiply@Functions@MathLibrary@@SANNN@Z = @ILT+745(?Multiply@Functions@MathLibrary@@SANNN@Z)
4 3 000110F5 Add = @ILT+240(_Add)
5 4 00011073 AddMultiply = @ILT+110(_AddMultiply)
6 5 0001105F Multiply = @ILT+90(_Multiply)
Now I want to use the Functions in an Excel-VBA Project like this:
Declare Function LIB_AddMultiply Lib "C:\Users\xxxx\source\repos\HelloDLL\Debug\HelloDLL.dll" Alias "AddMultiply" (ByVal a As Double, ByVal b As Double) As Double
Public Sub test()
Dim a As Double
Dim b As Double
a = 3
b = 4
Dim c As Double
c = LIB_AddMultiply(a, b)
MsgBox ("hi " + c)
End Sub
But whenever I want to run the test()
I get a Bad DLL Calling convention; Error 49
.
I already looked at the following (and some other) resources, but couldn't resolve my problem:
Do you have any advice?
Thanks a lot...
UPDATE:
This is the code for the header file:
#pragma once
#ifdef MATHLIBRARY_EXPORTS
#define MATHLIBRARY_API __declspec(dllexport)
#else
#define MATHLIBRARY_API __declspec(dllexport)
#endif
namespace MathLibrary
{
class Functions
{
public:
static MATHLIBRARY_API double Add(double a, double b);
//[...]
};
extern "C" MATHLIBRARY_API double Add(double a, double b)
{
return MathLibrary::Functions::Add(a, b);
}
//[...]
}