Search code examples
c++-clidllimport

error LNK2020: unresolved token (06000001) XXNET.XXNETDATA::.ctor with Interface


I have a XXNETDATA class in c++ library 1. and its derive class PURNETDATA in c++ library2.

XXNET.H 

namespace WM
{
namespace XXNET
{
public ref class XXNETDATA abstract
    {
    public:
        // Start Constructor/Destructor
        XXNETDATA();
        ~XXNETDATA();
        virtual int         assignNewKey(RWCString &Key) abstract;
        virtual public  String^     getKey(XX* &pXx) ;
  }
}

PURNET.H
#using "WM.XXNETDATA.WMD.dll"
using namespace WM::XXNET;
namespace WM
{
 namespace NETDATA
 {
 public ref class PURNETDATA : public XXNETDATA
    {
    public:
        // Start Constructor/Destructor
        PURNETDATA (const char* filterString,const char* SortString);
        ~PURNETDATA();
        virtual int assignNewKey(RWCString &Key) override;
        virtual String^ getKey(XX* &pXx) override;
    }
}

Here I don't get compilation error, but linker error as below

error LNK2020: unresolved token (06000001) WM.XXNET.XXNETDATA::.ctor

error LNK2020: unresolved token (06000010) WM.XXNET.XXNETDATA::getKey

Note: Both libraries are compiled using /clr option.


Solution

  • Class WPRNET.CPP includes WXXNET.h file which doesn't required. because both are managed CPP file and assembly(.dll) contains metadata information, which doesn't require .h files(native defination) to be included.