-2

I've a header file having a "extern class definition" in it. Both these header file and class are in different C++ assembly. Now there is a class in different C++ assembly which is trying to access this "extern" class functions but there are all sorts of linker errors such as LNK2001: unresolved external symbol " class LMSystem LM"(?LM@@3VLMSystem@@A),LNK2019 etc.

Following is the code snippet:for CPP file

/This header file contains the extern reference/

#include "../lm/lm.h"



BOOL FDInitHW (void) 
{ 
   char pFileName[TALLY_MAX_PATH];

   ASSERT(0 != g_pFdbPath);
   strcpy(pFileName, g_pFdbPath);
   strcat(pFileName, FILENAME_HW_KB);

   return SUCCESS == LM.LMIOListReadSelective(pFileName, 
                           LMIO_READREPLACE, FDGetSelectListPtrArray()); 
}

Contents of Lm.h

class LMSystem
{
public:   
   LMSystem();
   ~LMSystem();

   // getting a specific list
   short  LMIOListReadSelective(char *fname, unsigned short readflags, LIST_SELECTOR* select_array[]);
}; 
    extern LMSystem LM;  // the library global LMSytem

So can you help me in resolving this linker error? I think it has to do something with project properties as the old assembly developed in VC++ 6.0 is working fine and even in this Win32 C++ assembly,which I'm creating in VS2012,I'm able to go to definition of the LMSystem class using F12 or Intellisense but ideally it should point me to the variable in LM.H header file. I've seen many post telling how to use functions of one type defined in different C++.dll in another C++ .dll. There are many project level settings changes but it doesn't always give me the correct results. So if anybody can give me a solution to this issue then it will be great help.

Bobby
  • 169
  • 1
  • 2
  • 9

1 Answers1

1

Instance of LM needs to be created somewhere and your linker must be able to find it. For example add LMSystem LM; to one of your source (.cpp) files

Peter Petrik
  • 9,701
  • 5
  • 41
  • 65
  • It is already getting created in a .cpp class,so the _declspec dllexport problem is solved but there is one other external linking error. – Bobby Aug 05 '14 at 18:37