Dll linking error: 2019

Hi, All

I have a .dll file which exports a function called GetData().

The header file RegSys.h contains:

__declspec(dllexport) int GetData();

The source file RegSys.cpp contains:

int CRegSysApp::GetData()

{

return 100; // sample code to simply the question

}

The client application imports this function:

The header file TestBench.h contains:

__declspec(dllimport) int GetData();

The source file TestBench.cpp contains:

BOOL CTestBenchApp::InitInstance(void)

{

int nData = GetData();

if(nData ==100)

return TRUE;

}

I did include RegSys.lib, RegSys.dll and RegSys.h in the corresponding TestBench folders. It gave me the errors:

TestBench error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl GetData(void)" (__imp_ GetData@@YAHXZ) referenced in function "public: virtual int __thiscall CTestBenchApp::InitInstance(void)" ( InitInstance@CTestBenchApp@@UAEHXZ)
TestBench fatal error LNK1120: 1 unresolved externals

Any comments will be highly appreciated!

GS




Answer this question

Dll linking error: 2019

  • Pi314159

    Based on the information provided it looks as if you are trying to export a function of a class.

    __declspec(dllexport) int GetData(); ========> is this part of a class

    The source file RegSys.cpp contains:

    int CRegSysApp::GetData()

    {

    return 100; // sample code to simply the question

    }

    but when you import you are importing it as a global function

    __declspec(dllimport) int GetData();

    I hope you understand now why the compiler is complaining.


  • cbueno

    Thanks a lot! It was resolved.

  • Dll linking error: 2019