I'm returning a pointer to an API that I have housed inside a DLL, and I'm pretty sure (I've done this a few times before) that I have everything coded right. But when I go to compile the program that will call the DLL, I'm getting a linker error about the deconstructor of the API. Here's the code and the error:
if( !cmdLine.find("noupdate"))
{
#ifdef _WIN32
// why does windows always have to be different?
if(HINSTANCE h=LoadLibrary("surveNET.dll"))
{
typedef ISurveAPI* (*EXPORTAPI) ();
EXPORTAPI pfnExport;
if( !(pfnExport = (EXPORTAPI) GetProcAddress(h,"ExportAPI")) )
{
::MessageBoxA(NULL,"Failed loading surveNET.dll; please check your installation.\nec0",
"Error",MB_OK|MB_ICONSTOP);
return -1;
}
shared_ptr<ISurveAPI> pSurve = shared_ptr<ISurveAPI> ( pfnExport() );
::FreeLibrary(h);
}
else
{
::MessageBoxA(NULL,"Failed loading surveNET.dll; please check your installation.\nec1",
"Error", MB_OK|MB_ICONSTOP);
return -1;
}
#endif
return -1;
}
main.obj : error LNK2019: unresolved external symbol "public: __thiscall ISurveAPI::~ISurveAPI(void)" (??1ISurveAPI@@QAE@XZ) referenced in function "public: void * __thiscall ISurveAPI::`scalar deleting destructor'(unsigned int)" (??_GISurveAPI@@QAEPAXI@Z)
../../bin/launch.exe : fatal error LNK1120: 1 unresolved externals
I know I'm probably missing something blatently stupid. But here's also the header file that is being used for both the DLl complication and the inclusion for the library in the main program.
class ISurveAPI
{
public:
// constructor/destructor
ISurveAPI(void);
ISurveAPI(const ISurveAPI&);
~ISurveAPI(void);
};