Instead of exporting items, export the entire class one by one. In addition, I donβt completely know how this code can work - you did not specify a definition for sum() (the missing class scope operator) and what the linker should refer to (instead of math::Sum() you defined a new global sum() ).
mathAPI.h
#ifdef __APIBUILD #define __API __declspec(dllexport) #else #define __API __declspec(dllimport) #endif class __API math
Dll.cpp
#include "mathAPI.h" double math::Pi = 3.14; double math::Sum(double x, double y)
What is it.
EDIT
However, you should still receive an error message. This is because you made a typo that I did not notice (and you did not publish the real code!). In your Dll.cpp , you wrote:
double math::Pi = 3.14;
Although you posted something else, I'm sure your class has the name Math , not Math , because the linker is trying to find:
?Pi@Math @@2NA
So he looks in the Math class. This is the most likely assumption. Although, I am sure that you did not publish the real code, but a handwritten fragment.
source share