{
...
HINSTANCE hDll = LoadLibrary("Calculator.dll");
typedef CCalculator* (*CreateCalculator)();
CreateCalculator lpCreateCalcualtor;
lpCreateCalcualtor = (CreateCalculator)GetProcAddress(hDll, "CreateCalculator");
CCalculator* pCalculator = lpCreateCalcualtor();
int val = pCalculator->Add(10, 20);
CString msg;
msg.Format("%d", val);
MessageBox(msg);
FreeLibrary(hDll);
...
}
#ifdef CALCULATOR_EXPORTS
#define CALCULATOR_API __declspec(dllexport)
#else
#define CALCULATOR_API __declspec(dllimport)
#endif
class CCalculator
{
public:
CCalculator(void);
int Add(int a, int b);
int Sub(int a, int b);
};
extern "C" CALCULATOR_API CCalculator* CreateCalculator();
2>DllTestDlg.obj : error LNK2019: "public: int __thiscall CCalculator::Add(int,int)" (?Add@CCalculator@@QAEHHH@Z) 외부 기호(참조 위치: "protected: virtual int __thiscall CDllTestDlg::OnInitDialog(void)" (?OnInitDialog@CDllTestDlg@@MAEHXZ) 함수)에서 확인하지 못했습니다.
2>D:\Project\cpp\DllTest\Debug\DllTest.exe : fatal error LNK1120: 1개의 확인할 수 없는 외부 참조입니다.
왜 이런 링크에러가 뜨졍??
댓글 0