Link to home
Start Free TrialLog in
Avatar of makman111
makman111

asked on

DllGetClassObject Errors during compile

The following code give me errors (below)

HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
      if(memcmp(&rclsid,&CLSID_VdjPlugin,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
            if(memcmp(&riid,&IID_IVdjPluginDevice,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
                  *ppObject=new KC0DefaultMapper();
      return NO_ERROR;
}

IVdjPluginDevice.h
//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJCLASSGUID_DEFINED
#define VDJCLASSGUID_DEFINED
static const GUID CLSID_VdjPlugin = { 0x2e1480fe, 0x4ff4, 0x4539, { 0x90, 0xb3, 0x64, 0x5f, 0x5d, 0x86, 0xf9, 0x3b } };
#else
extern static const GUID CLSID_VdjPlugin;
#endif

//////////////////////////////////////////////////////////////////////////
// DLL export function

#ifndef NODLLEXPORT
#ifdef __cplusplus
extern "C" {
#endif
VDJ_EXPORT HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject);
#ifdef __cplusplus
}
#endif
#endif

//////////////////////////////////////////////////////////////////////////

VdjPlugin.h
//////////////////////////////////////////////////////////////////////////
// GUID definitions

#ifndef VDJDEVICEGUID_DEFINED
#define VDJDEVICEGUID_DEFINED
static const GUID IID_IVdjPluginDevice = { 0xc17ed55e, 0x76b2, 0x4fb7, { 0x99, 0x34, 0xbb, 0xb1, 0xaf, 0xcd, 0x8c, 0x7b } };
#else
extern static const GUID IID_IVdjPluginDevice;
#endif

//////////////////////////////////////////////////////////////////////////


COMPILE ERRORS
------ Build started: Project: TotalControl, Configuration: Debug Win32 ------
Linking...
   Creating library TotalControl.lib and object TotalControl.exp
TotalControl.obj : error LNK2028: unresolved token (0A000031) "public: __thiscall KC0DefaultMapper::KC0DefaultMapper(void)" (??0KC0DefaultMapper@@$$FQAE@XZ) referenced in function "extern "C" long __stdcall DllGetClassObject(struct _GUID const &,struct _GUID const &,void * *)" (?DllGetClassObject@@$$J212YGJABU_GUID@@0PAPAX@Z)
TotalControl.obj : error LNK2019: unresolved external symbol "public: __thiscall KC0DefaultMapper::KC0DefaultMapper(void)" (??0KC0DefaultMapper@@$$FQAE@XZ) referenced in function "extern "C" long __stdcall DllGetClassObject(struct _GUID const &,struct _GUID const &,void * *)" (?DllGetClassObject@@$$J212YGJABU_GUID@@0PAPAX@Z)
TotalControl.dll : fatal error LNK1120: 2 unresolved externals
Avatar of jkr
jkr
Flag of Germany image

Are you sure you added the .cpp file that holds "KC0DefaultMapper" to you project?
Avatar of makman111
makman111

ASKER

#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
//#include <stdio.h>
#include "stdafx.h"
#include "KC0Mapper.h"
#include "VdjPlugin.h"
#include "vdjDevice.h"

// Mapper class
class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};
// Set device type
HRESULT KC0DefaultMapper::GetDeviceType(int *type)
{
      *type = PLUGINDEVICE_TOTALCONTROL;
      return(PLUGINDEVICE_TOTALCONTROL);
}


HRESULT KC0DefaultMapper::OnSlider(int chan,int slider,int absvalue,int relvalue)
{
      char cmd[32];

      switch(slider)
      {
            case KC0_SLID_CROSSFADER:
            wsprintf(cmd,"video_crossfade %d",absvalue);
            SendCommand(cmd,chan);
            break;
      }
      return 0;
}

// Return information about plugin
HRESULT KC0DefaultMapper::OnGetPluginInfo(TVdjPluginInfo *infos)
{
      static char st[128];

      infos->PluginName = ".";
      infos->Author = ".";
      infos->Description = ".";
      infos->Flag = 0;

      infos->Bitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(100));

      return S_OK;
}

//-----------------------------------------------------------------------------
HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
      if(memcmp(&rclsid,&CLSID_VdjPlugin,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
            if(memcmp(&riid,&IID_IVdjPluginDevice,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
                  *ppObject=new KC0DefaultMapper();
      return NO_ERROR;
}
//-----------------------------------------------------------------------------
Do I need to move this code to from tc.cpp to tc.h?  If I do what would the new tc.cpp main() have in it?
No, not at all, just make sure that it is included in your project. Go to "Project|Add..|Existing Item..." and navigate to that file. The, double-click and select "OK"  to add it to the project.

It's there (same as before).  Same problem.
Hm, the constructor seems to be missing - what happens if you add

KC0DefaultMapper::KC0DefaultMapper() {

// empty
}

to your code?
>>Hm, the constructor seems to be missing

Make that read

Hm, the default constructor seems to be missing
That should be in the class definitation correct?

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

      KC0DefaultMapper::KC0DefaultMapper()  
     {return 0;}
};

or outside of it

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};

KC0DefaultMapper::KC0DefaultMapper()  
{return 0;}
You can choose either location, but constructors don't return values, so that has to be either

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

      KC0DefaultMapper::KC0DefaultMapper()  {}
};

or

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};

KC0DefaultMapper::KC0DefaultMapper()  {}

SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);
};

KC0DefaultMapper::KC0DefaultMapper(){
      //empty
}

Gives me:

------ Build started: Project: TotalControl, Configuration: Debug Win32 ------
Compiling...
TotalControl.cpp
.\TotalControl.cpp(13) : error C2653: 'KC0DefaultMapper' : is not a class or namespace name
.\TotalControl.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\TotalControl.cpp(13) : warning C4508: 'KC0DefaultMapper' : function should return a value; 'void' return type assumed
.\TotalControl.cpp(70) : error C2061: syntax error : identifier 'KC0DefaultMapper'
TotalControl - 3 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Compiling...
TotalControl.cpp
.\TotalControl.cpp(13) : error C2653: 'KC0DefaultMapper' : is not a class or namespace name
.\TotalControl.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\TotalControl.cpp(13) : warning C4508: 'KC0DefaultMapper' : function should return a value; 'void' return type assumed
.\TotalControl.cpp(25) : error C2535: 'KC0DefaultMapper::KC0DefaultMapper(void)' : member function already defined or declared
        .\TotalControl.cpp(19) : see declaration of 'KC0DefaultMapper::KC0DefaultMapper'
.\TotalControl.cpp(69) : error C2061: syntax error : identifier 'KC0DefaultMapper'
I did some messing around - this worked....  But I do not know why

#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
//#include <stdio.h>
#include "stdafx.h"
#include "KC0Mapper.h"
#include "VdjPlugin.h"
#include "vdjDevice.h"

// Mapper class

class KC0DefaultMapper:public IVdjPluginDevice
{
      public:
      KC0DefaultMapper();

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);

};
KC0DefaultMapper::KC0DefaultMapper()  {}
// Set device type
HRESULT KC0DefaultMapper::GetDeviceType(int *type)
{
      *type = PLUGINDEVICE_TOTALCONTROL;
      return(PLUGINDEVICE_TOTALCONTROL);
}


HRESULT KC0DefaultMapper::OnSlider(int chan,int slider,int absvalue,int relvalue)
{
      char cmd[32];

      switch(slider)
      {
            case KC0_SLID_CROSSFADER:
            wsprintf(cmd,"video_crossfade %d",absvalue);
            SendCommand(cmd,chan);
            break;
      }
      return 0;
}

// Return information about plugin
HRESULT KC0DefaultMapper::OnGetPluginInfo(TVdjPluginInfo *infos)
{
      static char st[128];

      infos->PluginName = ".";
      infos->Author = ".";
      infos->Description = ".";
      infos->Flag = 0;

      infos->Bitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(100));

      return S_OK;
}

//-----------------------------------------------------------------------------
HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
      if(memcmp(&rclsid,&CLSID_VdjPlugin,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
            if(memcmp(&riid,&IID_IVdjPluginDevice,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
                  *ppObject=new KC0DefaultMapper();
      return NO_ERROR;
}
//-----------------------------------------------------------------------------
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah - your a probably right.  Thanks for the help.  I have another question coming - you are great, please check it out.

https://www.experts-exchange.com/questions/22880489/c-over-riding.html
I gotta hit the sack (we're talking MEDT at the moment), will take a look tomorrow ;o)