How to include a DLL in a DLL in VS 2019 Professional

  • Thread starter Thread starter ananda vardhana
  • Start date Start date
A

ananda vardhana

Guest
I did two experiments:

Expt 1: I wrote a exe file and a lib(insert 1 & 2). I built the lib and dll first. Copied over the lib and DLL to the appropriate folder. Went to the properties of both C++/General and Linker/Input/Additional Libraries and for the exe and set everything correctly and this works fine But I get squiggly under GetRdtData where I define it as extern saying that it is not found. However it builds and works fine. So please advice how to get rid of that squiggly line. This was not happening in VS 2017

Expt 2: What I really want to include is a DLL in a DLL. So please scroll down to the third insert. From that DLL I want to call the DLL in the second insert. The third DLL code does not link and I still have the squiggly under extern GetRdtData(). Here also I have done the C++ and Linker Properties setting. This is the error I get. Kindly help me get this resolved

1>TestDll.obj : error LNK2019: unresolved external symbol GetRdtData referenced in function OpenSigGenPerformanceData
1>D:\work\sample\rdt\dll\x64\Debug\TestDll.dll : fatal error LNK1120: 1 unresolved externals

#include <windows.h>
#include <stdio.h>
#include <string.h>

extern void GetRdtData(DWORD VmInstance, DWORD* RdtData);

void main()
{
DWORD i = 0, rdtData[3];
GetRdtData(i, rdtData);
}

and in the library I did:

_declspec(dllexport)
void GetRdtData(
DWORD VmInstance,
DWORD *RdtData
);

_declspec(dllexport)
void GetRdtData(
DWORD VmInstance,
DWORD *RdtData
)
{
*RdtData++ = 123;
*RdtData++ = 456;
*RdtData = 897;
return;
}

Here is the DLL code for Expt 2:

extern void GetRdtData(DWORD VmInstance, DWORD* RdtData);

_declspec(dllexport)
DWORD OpenSigGenPerformanceData(
LPWSTR lpDeviceNames
);

_declspec(dllexport)
DWORD OpenSigGenPerformanceData(
LPWSTR lpDeviceNames
)
{
DWORD rdtData[3];

for (DWORD i = 0; i < 5; i++) {
GetRdtData(i, rdtData);
}

return (0);
}

Continue reading...
 
Back
Top