views:

71

answers:

1

Here's the scenario:

Platform: VS2005 and language is VC++

Situation: There's just 1 assembly CMPW32. It has 2 projects: 1 is a DLL project called CMPW32 and the 2nd one is an .exe project called Driver They both share the same Debug folder under the main assembly folder. I have been able to successfully export a few functions from the DLL. The Driver project accesses 1 of these exported functions. (First of all I am not if functions need to be exported for projects in the SAME assembly to be able to use them. I can just include the header files and use the functions I think.)

Following is are a few lines of code from some files which you might find useful to analyze my problem:

//main.cpp file from the Driver project which is meant to generate Driver.exe

#pragma comment(lib, "winmm.lib")
#include <CM.h>
#include "conio.h"
#include "CMM.h"
#include "CMF.h"
#define C_M_F    _T("c:\\CannedMessages.en-US")
int_tmain (int argc, TCHAR* argv [])
{
    CMM myobjModel;
    CMF::Read (CANNED_MESSAGES_FILE, myobjModel);
    getch();
}

//CMM.h file
#ifndef C_M_M
#define C_M_M
#include "CMD.h"
#include "CMC.h"
#include "CM.h"
#define _C_M_DLL
#include "CMP.h"
class CM_DLL_API CMM
{  //some code here...
}


//CMF.h
#ifndef C_M_F
#define C_M_F
#include "CMM.h"
#define _C_M_DLL
#include "CMP.h"
class CM_DLL_API CMF 
{ //some code here...
}

//CMP.h
#ifndef C_M_P
#define C_M_P
#include "CMD.h"
#define C_M_B_F   _T("CannedMessages.")
#ifdef _C_M_DLL
#define CM_DLL_API __declspec( dllexport ) 
#else
#define CM_DLL_API __declspec( dllimport )
#endif
extern "C"
{
//list of functions to be exported..
}

ERRORS on building the solution:

Error13 error LNK2019: unresolved external symbol "public: __thiscall CMM::~CMM(void)" (??1CMM@@QAE@XZ) referenced in function _wmain main.obj

Error15 fatal error LNK1120: 2 unresolved externals C:\"somepath here which I cant disclose"\Projects\CMPW32\Debug\Driver.exe

Please Note: If I choose to build only the CMPW32 DLL project, there are no errors and the CMPW32.dll file gets generated in the debug folder with the correct functions getting getting exported. However there seems to be some linking problem that is pretty evident and I don't know what's going on. I have included every required file and also have entered the required .lib in the input of the "Project Settings". The paths have been set correctly too.

It would be really helpful if someone could help me out with this. Please lemme know if additional information required.

Thanks, Viren

+3  A: 

Looks like your Driver.exe project does not include the CPP source files of the CMM class, likely CMM.cpp.

or

You have declare a destructor for CMM class in your .H file (CMM.H) and forgot to implement it in the .CPP file (CMM.CPP).

Remus Rusanu
The destructor is in the CMM.cpp file.
VP